-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathvite.config.ts
More file actions
79 lines (77 loc) · 2.59 KB
/
vite.config.ts
File metadata and controls
79 lines (77 loc) · 2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import { defineConfig, loadEnv } from 'vite';
import vue from '@vitejs/plugin-vue';
import Components from 'unplugin-vue-components/vite';
import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers';
import AutoImport from 'unplugin-auto-import/vite';
import vueJsx from '@vitejs/plugin-vue-jsx';
import viteCompression from 'vite-plugin-compression';
import { visualizer } from 'rollup-plugin-visualizer';
import * as path from 'path';
// https://vitejs.dev/config/
export default ({ mode }: { mode: string }) => {
const env = loadEnv(mode, './');
console.log(env);
return defineConfig({
css: {
preprocessorOptions: {
less: {
additionalData: `@import "${path.resolve(
__dirname,
'./src/theme/variable/variable.less'
)}";`,
modifyVars: {
'primary-color': '#3D50FF',
'border-radius-base': '4px'
},
javascriptEnabled: true
}
}
},
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
'~': path.resolve(__dirname, './node_modules')
}
},
plugins: [
vue(),
vueJsx(),
Components({
dts: 'src/types/globalComponents.d.ts',
dirs: ['src/components'], // Folders for on-demand loading
resolvers: [AntDesignVueResolver({ importStyle: 'less' })]
}),
AutoImport({
imports: ['vue', 'vue-router', 'pinia'], // Auto import vue and vue-router related functions
dts: 'src/types/autoImport.d.ts' // Generate `auto-import.d.ts` global declarations
}),
viteCompression({
ext: '.gz',
verbose: true,
deleteOriginFile: false
}),
visualizer()
],
server: {
fs: {
strict: true,
allow: ['.']
},
host: true,
port: 3000,
open: 'http://localhost:3000'
},
build: {
// Remove console and error configurations in production build
minify: 'terser',
terserOptions: {
compress: {
drop_console: true,
drop_debugger: true
}
},
sourcemap: mode !== 'production',
cssTarget: 'chrome61'
}
});
};