-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
68 lines (65 loc) · 1.4 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
import { defineConfig, loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'
import viteCompression from 'vite-plugin-compression'
// yarn add vite-plugin-html -D
import { createHtmlPlugin } from 'vite-plugin-html'
const path = require('path')
const process = require('process')
const envResolve = (mode) => {
return loadEnv(mode, process.cwd())
}
const TITLE = process.env.VITE_APP_TITLE
const PORT = process.env.VITE_APP_PORT
// https://vitejs.dev/config/
export default defineConfig({
base: './', //打包路径
plugins: [
vue(),
createHtmlPlugin({
minify: true,
inject: {
data: {
title: TITLE,
},
},
}),
// gzip压缩 生产环境生成 .gz 文件
viteCompression({
verbose: true,
disable: false,
threshold: 10240,
algorithm: 'gzip',
ext: '.gz',
}),
],
// 配置别名
resolve: {
alias: {
'@': path.resolve(__dirname, 'src'),
},
},
css: {
preprocessorOptions: {
scss: {
additionalData: '@import "@/assets/style/main.scss";',
},
},
},
server: {
port: PORT,
open: true,
https: false,
proxy: {},
},
build: {
minify: 'terser',
terserOptions: {
compress: {
// eslint-disable-next-line camelcase
drop_console: true,
// eslint-disable-next-line camelcase
drop_debugger: true,
},
},
},
})