-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathvite.config.ts
82 lines (80 loc) · 2.45 KB
/
vite.config.ts
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
80
81
82
// @ts-ignore
import path, { resolve } from 'path'
import uni from '@dcloudio/vite-plugin-uni'
import viteSvgIcons from 'vite-plugin-svg-icons'
import vueJsx from '@vitejs/plugin-vue-jsx'
import setting from './src/settings'
//auto import vue https://www.npmjs.com/package/unplugin-auto-import
import AutoImport from 'unplugin-auto-import/vite'
export default ({ command, mode }) => {
console.log('command', command)
return {
base: setting.viteBasePath,
plugins: [
uni(),
vueJsx(),
// #ifdef H5
viteSvgIcons({
// config svg dir that can config multi
iconDirs: [path.resolve(process.cwd(), 'src/icons/common'), path.resolve(process.cwd(), 'src/icons/nav-bar')],
// appoint svg icon using mode
symbolId: 'icon-[dir]-[name]'
}),
// #endif
//https://github.com/antfu/unplugin-auto-import/blob/HEAD/src/types.ts
AutoImport({
// resolvers: [ElementPlusResolver()],
imports: [
'vue',
'vue-router',
{
'@/hooks/global/useCommon': ['useCommon'],
'@/utils/uniRequest': ['uniRequest']
}
],
eslintrc: {
enabled: true, // Default `false`
filepath: './.eslintrc-auto-import.json', // Default `./.eslintrc-auto-import.json`
globalsPropValue: true // Default `true`, (true | false | 'readonly' | 'readable' | 'writable' | 'writeable')
},
dts: true //auto generation auto-imports.d.ts file
})
],
build: {
brotliSize: false,
// 消除打包大小超过500kb警告
chunkSizeWarningLimit: 2000,
//remote console.log in prod
terserOptions: {
//detail to look https://terser.org/docs/api-reference#compress-options
compress: {
drop_console: false,
pure_funcs: ['console.log', 'console.info'],
drop_debugger: true
}
},
//build assets Separate
assetsDir: 'static/assets',
rollupOptions: {
output: {
chunkFileNames: 'static/js/[name]-[hash].js',
entryFileNames: 'static/js/[name]-[hash].js',
assetFileNames: 'static/[ext]/[name]-[hash].[ext]'
}
}
},
resolve: {
alias: {
'@': resolve(__dirname, 'src')
}
},
css: {
preprocessorOptions: {
//define global scss variable
scss: {
additionalData: `@import "@/common/variables.scss";`
}
}
}
}
}