| | |
| | | |
| | | import { generateModifyVars } from './build/config/themeConfig'; |
| | | import { createProxy } from './build/vite/proxy'; |
| | | import { createAlias } from './build/vite/alias'; |
| | | import { wrapperEnv } from './build/utils'; |
| | | import { createVitePlugins } from './build/vite/plugin'; |
| | | import { OUTPUT_DIR } from './build/constant'; |
| | | |
| | | function pathResolve(dir: string) { |
| | | return resolve(__dirname, '.', dir); |
| | | } |
| | | |
| | | export default ({ command, mode }: ConfigEnv): UserConfig => { |
| | | const root = process.cwd(); |
| | |
| | | // The boolean type read by loadEnv is a string. This function can be converted to boolean type |
| | | const viteEnv = wrapperEnv(env); |
| | | |
| | | const { VITE_PORT, VITE_PUBLIC_PATH, VITE_PROXY, VITE_DROP_CONSOLE, VITE_LEGACY } = viteEnv; |
| | | const { VITE_PORT, VITE_PUBLIC_PATH, VITE_PROXY, VITE_DROP_CONSOLE } = viteEnv; |
| | | |
| | | const isBuild = command === 'build'; |
| | | |
| | |
| | | base: VITE_PUBLIC_PATH, |
| | | root, |
| | | resolve: { |
| | | alias: [ |
| | | { |
| | | // /@/xxxx => src/xxx |
| | | find: /^\/@\//, |
| | | replacement: pathResolve('src') + '/', |
| | | }, |
| | | { |
| | | // /@/xxxx => src/xxx |
| | | find: /^\/#\//, |
| | | replacement: pathResolve('types') + '/', |
| | | }, |
| | | ], |
| | | alias: createAlias([ |
| | | // /@/xxxx => src/xxxx |
| | | ['/@/', 'src'], |
| | | // /#/xxxx => types/xxxx |
| | | ['/#/', 'types'], |
| | | ]), |
| | | }, |
| | | server: { |
| | | port: VITE_PORT, |
| | | // Load proxy configuration from .env |
| | | proxy: createProxy(VITE_PROXY), |
| | | hmr: { |
| | | overlay: true, |
| | | }, |
| | | }, |
| | | |
| | | build: { |
| | | target: 'es2015', |
| | | outDir: OUTPUT_DIR, |
| | | polyfillDynamicImport: VITE_LEGACY, |
| | | terserOptions: { |
| | | compress: { |
| | | keep_infinity: true, |