generated from Merlin218/vite-template-vue3-typescript
-
Notifications
You must be signed in to change notification settings - Fork 5
/
vite.config.ts
93 lines (92 loc) · 2.2 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
83
84
85
86
87
88
89
90
91
92
93
/*
* @Author: Merlin218
* @Date: 2022-01-30 17:06:39
* @LastEditors: Merlin218
* @LastEditTime: 2022-02-10 01:11:28
* @Description: 请填写简介
*/
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import path from 'path';
import styleImport from 'vite-plugin-style-import';
// import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers';
// import Components from 'unplugin-vue-components/vite';
import configs from './src/configs';
// https://vitejs.dev/config/
export default defineConfig({
// base: '/data-to-chart/',
plugins: [
vue(),
// Components({
// dirs: ['src/**/*'],
// resolvers: [
// AntDesignVueResolver(), // ant-design-vue
// ],
// dts: 'src/components.d.ts',
// }),
styleImport({
libs: [
{
libraryName: 'ant-design-vue',
esModule: true,
resolveStyle: name => {
return `ant-design-vue/es/${name}/style/index`;
},
},
],
}),
],
server: {
proxy: {
'/api': {
target: configs.proxyUrl,
changeOrigin: true,
rewrite: path => {
return path.replace(/^\/api/, '');
},
},
},
},
resolve: {
// 配置路径别名
alias: {
'@': path.resolve(__dirname, './src'),
api: path.resolve(__dirname, './src/api'),
comps: path.resolve(__dirname, './src/components'),
pages: path.resolve(__dirname, './src/pages'),
utils: path.resolve(__dirname, './src/utils'),
configs: path.resolve(__dirname, './src/configs'),
store: path.resolve(__dirname, './src/store'),
types: path.resolve(__dirname, './src/types'),
},
extensions: ['.js', '.json', '.ts'], // 使用路径别名时想要省略的后缀名,可以自己 增减
},
build: {
terserOptions: {
compress: {
//生产环境时移除console
drop_console: true,
drop_debugger: true,
},
},
// 取消计算文件大小,加快打包速度
brotliSize: false,
// sourcemap: true,
// assetsDir: 'static/img',
rollupOptions: {
output: {
chunkFileNames: 'js/[name]-[hash].js',
entryFileNames: 'js/[name]-[hash].js',
assetFileNames: '[ext]/[name]-[hash].[ext]',
},
// 配置CDN
},
},
css: {
preprocessorOptions: {
less: {
javascriptEnabled: true,
},
},
},
});