-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.js
More file actions
75 lines (70 loc) · 1.99 KB
/
vite.config.js
File metadata and controls
75 lines (70 loc) · 1.99 KB
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
import { fileURLToPath, URL } from 'node:url'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
// Element plus
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
// 图片打包输出插件
// import copy from 'rollup-plugin-copy'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
vue(),
AutoImport({
resolvers: [ElementPlusResolver()]
}),
Components({
resolvers: [ElementPlusResolver()]
})
// 图片打包输出
// copy({
// patterns: [
// { from: 'src/assets', to: 'dist/img' } // 配置图片文件的源路径和目标路径
// ]
// })
],
base: './',
build: {
minify: 'terser',
terserOptions: {
compress: {
// 生产环境时移除console
drop_console: true,
drop_debugger: true
}
},
chunkSizeWarningLimit: 800 * 1024, // 设置打包后模块大小为800kb
rollupOptions: {
output: {
// manualChunks: (id) => {
// if (id.endsWith('.css')) {
// return 'css'
// } else if (id.endsWith('.js')) {
// return 'js'
// } else if (/\.(png|jpe?g|gif|svg|ico)(\?.*)?$/.test(id)) {
// return 'img'
// }
// }
entryFileNames: 'js/[name].[hash].js', // 配置输出的js文件路径和名称
// chunkFileNames: 'img/[name].[hash].js', // 配置输出的chunk js文件路径和名称
assetFileNames: 'css/[name].[ext]' // 配置输出的css文件路径和名称
}
}
// assetsDir: 'assets' // 配置输出的图片文件路径
},
server: {
proxy: {
'/api': {
target: 'http://localhost:3001',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, '')
}
}
},
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
}
})