Vben
2021-03-31 8a14069e71d5393cfa5b758f46a1c5c001fa172b
vite.config.ts
@@ -5,13 +5,10 @@
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();
@@ -21,7 +18,7 @@
  // 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';
@@ -29,33 +26,21 @@
    base: VITE_PUBLIC_PATH,
    root,
    resolve: {
      alias: [
        {
          // /@/xxxx  =>  src/xxx
          find: /^\/@\//,
          replacement: pathResolve('src') + '/',
        },
        {
          // /#/xxxx  =>  types/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: {
      cssCodeSplit: false,
      // minify: 'esbuild',
      target: 'es2015',
      outDir: OUTPUT_DIR,
      polyfillDynamicImport: VITE_LEGACY,
      terserOptions: {
        compress: {
          keep_infinity: true,