-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.js
66 lines (65 loc) · 1.32 KB
/
vite.config.js
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
import { loadEnv, defineConfig } from 'vite'
import uni from '@dcloudio/vite-plugin-uni'
import { resolve } from 'path'
import viteCompression from "vite-plugin-compression";
import AutoImport from 'unplugin-auto-import/vite'
// https://vitejs.dev/config/
/** @type {import('vite').UserConfig} */
export default defineConfig(({ mode }) => {
const env = loadEnv(mode,process.cwd())
return {
plugins: [
uni(),
// AutoImport
AutoImport({
imports: ['vue','pinia','uni-app'],
// dts: false
}),
// GZIP comporession
viteCompression({
disable: true,
deleteOriginFile: true,
threshold: 10240,
algorithm: 'gzip',
ext: '.gz'
})
],
// alias config
resolve: {
alias: {
'@': resolve(__dirname, 'src')
}
},
// scss preprocessor
css: {
preprocessorOptions: {
scss: {
// addtionalData: `@use "@/src/styles/global.scss" as *;`
addtionalData: `@import "@/src/styles/global.scss";`
},
}
},
// local proxy
server: {
open: false,
host: true,
strictPort: true,
port: Number(env.VITE_APP_PORT),
proxy: {}
},
// production config
build: {
base: '/',
outDir: 'dist',
assetsDir: 'assets',
sourcemap: false,
minify: 'terser',
terserOptions: {
compress: {
drop_console: true,
drop_debugger: true,
}
}
}
}
});