-
Notifications
You must be signed in to change notification settings - Fork 198
/
vite.config.mts
116 lines (115 loc) · 3.4 KB
/
vite.config.mts
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
import type { ConfigEnv, UserConfigExport } from "vite";
import path from "path";
import autoprefixer from 'autoprefixer';
import AutoImport from 'unplugin-auto-import/vite';
import tailwindcss from 'tailwindcss';
import { include, exclude } from './build/optimize';
import { createVitePlugins } from './build/plugins';
export default ({ command, mode }: ConfigEnv): UserConfigExport => {
return {
base: "./", // publicPath
server: {
host: 'localhost',
port: 5173,
proxy: {
'/api': {
// target: 'https://yft.design',
target: 'http://127.0.0.1:8789',
changeOrigin: true,
rewrite: (path) => path.replace(new RegExp('^'), ''),
},
'/static': {
// target: 'https://yft.design',
target: 'http://127.0.0.1:8789',
changeOrigin: true,
rewrite: (path) => path.replace(new RegExp('^'), ''),
},
'/yft-static': {
// target: 'https://yft.design',
target: 'http://127.0.0.1:8789',
changeOrigin: true,
rewrite: (path) => path.replace(new RegExp('^'), ''),
},
},
},
plugins: createVitePlugins(mode),
optimizeDeps: { include, exclude },
css: {
postcss: {
plugins: [
tailwindcss,
autoprefixer({
// 自动添加前缀
overrideBrowserslist: [
'Android 4.1',
'iOS 7.1',
'Chrome > 31',
'ff > 31',
'ie >= 8',
'> 1%',
'last 2 versions',
'not dead',
'not ie 11',
//'last 2 versions', // 所有主流浏览器最近2个版本
],
grid: true,
}),
]
},
preprocessorOptions: {
scss: {
additionalData: `@import "src/assets/style/variable.scss";@import "src/assets/style/mixin.scss";`,
},
less: {
modifyVars: {
"primary-color": "#d14424",
"text-color": "#41464b",
"font-size-base": "13px",
"border-radius-base": "2px",
},
javascriptEnabled: true,
},
},
},
resolve: {
alias: {
"@": path.resolve(__dirname, "src"),
},
extensions: [".js", ".ts", ".jsx", ".tsx", ".vue", ".json"],
},
build: {
target: "es2015",
outDir: path.resolve(__dirname, "dist"),
minify: "terser",
terserOptions: {
compress: {
//生产环境时移除console
drop_console: true,
drop_debugger: true,
},
},
// 关闭文件计算
reportCompressedSize: false,
// 关闭生成map文件
sourcemap: false,
rollupOptions: {
output: {
// chunkFileNames: 'js/[name]-[hash].js', // 引入文件名的名称
// entryFileNames: 'js/[name]-[hash].js', // 包的入口文件名称
// assetFileNames: '[ext]/[name]-[hash].[ext]', // 资源文件像 字体,图片等
manualChunks: {
vue: ['vue'],
fabric: ['fabric'],
'lodash-es': ['lodash-es'],
'opentype.js': ['opentype.js'],
'clipper-lib': ['clipper-lib'],
'element-plus': ['element-plus'],
},
// manualChunks(id, any): string {
// return id
// }
}
}
},
};
};