From 8a14069e71d5393cfa5b758f46a1c5c001fa172b Mon Sep 17 00:00:00 2001 From: Vben <anncwb@126.com> Date: 星期三, 31 三月 2021 23:52:11 +0800 Subject: [PATCH] refactor: refactor dashboard --- vite.config.ts | 31 +++++++++---------------------- 1 files changed, 9 insertions(+), 22 deletions(-) diff --git a/vite.config.ts b/vite.config.ts index 927c1ea..2934a94 100644 --- a/vite.config.ts +++ b/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,31 +26,21 @@ 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, -- Gitblit v1.8.0