第六十一章-Vite配置-optimizeDeps.include

1.说明

Vite配置-optimizedeps-exclude说明

原文:

类型: string[]

默认情况下,不在 node_modules 中的,链接的包不会被预构建。使用此选项可强制预构建链接的包。

2.安装moment

antd中需要使用moment。而moment配置和本章有关,所以就顺便安装一下:

yarn add moment

3.配置Vite

vite.config.ts

// ...

function pathResolve(dir: string) {
  return resolve(__dirname, '.', dir);
}

export default ({ command, mode }: ConfigEnv): UserConfig => {
  // ...

  return {
    // ...
    optimizeDeps: {
      // @iconify/iconify: The dependency is dynamically and virtually loaded by @purge-icons/generated, so it needs to be specified explicitly
      include: [
        '@iconify/iconify',
        'ant-design-vue/es/locale/zh_CN',
        'moment/dist/locale/zh-cn',
        'ant-design-vue/es/locale/en_US',
        'moment/dist/locale/eu',
      ],
      // ...
    },
  };
};

上一章

第六十章-Vite插件-vite-plugin-pwa

下一章

第六十二章-Vite配置-optimizeDeps.exclude

# vben  vite 

评论

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×