| | |
| | | return defineConfig(async ({ command, mode }) => { |
| | | const root = process.cwd(); |
| | | const isBuild = command === 'build'; |
| | | const { VITE_USE_MOCK, VITE_BUILD_COMPRESS, VITE_ENABLE_ANALYZE } = loadEnv(mode, root); |
| | | const { VITE_PUBLIC_PATH, VITE_USE_MOCK, VITE_BUILD_COMPRESS, VITE_ENABLE_ANALYZE } = loadEnv( |
| | | mode, |
| | | root, |
| | | ); |
| | | |
| | | const defineData = await createDefineData(root); |
| | | const plugins = await createPlugins({ |
| | |
| | | const pathResolve = (pathname: string) => resolve(root, '.', pathname); |
| | | |
| | | const applicationConfig: UserConfig = { |
| | | base: VITE_PUBLIC_PATH, |
| | | resolve: { |
| | | alias: [ |
| | | { |
| | | find: 'vue-i18n', |
| | | replacement: 'vue-i18n/dist/vue-i18n.cjs.js', |
| | | }, |
| | | // /@/xxxx => src/xxxx |
| | | { |
| | | find: /\/@\//, |
| | | replacement: pathResolve('src') + '/', |
| | | }, |
| | | // /#/xxxx => types/xxxx |
| | | { |
| | | find: /\/#\//, |
| | | replacement: pathResolve('types') + '/', |
| | | }, |
| | | // @/xxxx => src/xxxx |
| | | { |
| | |
| | | cssTarget: 'chrome80', |
| | | rollupOptions: { |
| | | output: { |
| | | // 入口文件名 |
| | | entryFileNames: 'assets/entry/[name]-[hash].js', |
| | | manualChunks: { |
| | | vue: ['vue', 'pinia', 'vue-router'], |
| | | antd: ['ant-design-vue', '@ant-design/icons-vue'], |
| | |
| | | plugins, |
| | | }; |
| | | |
| | | const mergedConfig = mergeConfig(commonConfig, applicationConfig); |
| | | const mergedConfig = mergeConfig(commonConfig(mode), applicationConfig); |
| | | |
| | | return mergeConfig(mergedConfig, overrides); |
| | | }); |