12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- import { UserConfig, ConfigEnv, defineConfig } from 'vite'
- import { resolve } from 'path';
- import { createVitePlugins } from './vite/plugin';
- import { generateModifyVars } from './vite/themeConfig';
- import { proxy } from './vite/proxy';
- const root = process.cwd()
- // https://vitejs.dev/config/
- export default ({ command, mode }: ConfigEnv): UserConfig => {
- console.log('vite >>>', command, mode);
- const isBuild = command === 'build'
- return {
- root,
- resolve: {
- alias: [
- {
- find: /^@\//,
- replacement: resolve(root, './src') + '/'
- }
- ]
- },
- css: {
- preprocessorOptions: {
- less: {
- javascriptEnabled: true,
- modifyVars: generateModifyVars()
- }
- }
- },
- build: {
- target: 'es2015',
- terserOptions: {
- compress: {
- // TODO:
- keep_infinity: true,
- drop_console: true,
- drop_debugger: true
- }
- },
- // TODO:
- brotliSize: false,
- // TODO:
- chunkSizeWarningLimit: 2000,
- },
- plugins: createVitePlugins(isBuild),
- server: {
- hmr: {
- // 禁用服务器错误的遮罩层
- overlay: false
- },
- open: true,
- proxy
- }
- }
- }
|