-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
58 lines (56 loc) · 1.54 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
import path from 'node:path';
import process from 'node:process';
import vue from '@vitejs/plugin-vue';
import vueJsx from '@vitejs/plugin-vue-jsx';
import Unocss from 'unocss/vite';
import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers';
import Components from 'unplugin-vue-components/vite';
import { defineConfig, loadEnv } from 'vite';
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd());
return {
base: './',
resolve: {
alias: {
'@': path.resolve(import.meta.dirname, 'src'),
},
},
plugins: [
vue(),
vueJsx(),
Unocss(),
Components({
resolvers: [
AntDesignVueResolver({
importStyle: false, // css in js
}),
],
}),
],
// 反向代理解决跨域问题
server: {
// open: true,// 运行时自动打开浏览器
host: '0.0.0.0', // 局域网别人也可访问
port: Number(env.VITE_APP_PORT), // 端口号
},
esbuild: {
pure: env.VITE_NODE_ENV === 'production' ? ['console.log', 'debugger'] : [],
},
build: {
target: 'esnext',
outDir: env.VITE_OUT_DIR || 'dist',
chunkSizeWarningLimit: 2000,
rollupOptions: {
output: {
chunkFileNames: 'assets/js/[name]-[hash].js',
entryFileNames: 'assets/js/[name]-[hash].js',
assetFileNames: 'assets/[ext]/[name]-[hash].[ext]',
},
external: ['typescript'],
},
},
optimizeDeps: {
exclude: ['@vue/repl'],
},
};
});