-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.js
88 lines (87 loc) · 2.38 KB
/
vite.config.js
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
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { resolve } from 'path'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import ElementPlus from 'unplugin-element-plus/vite'
import { FileSystemIconLoader } from 'unplugin-icons/loaders'
import Icons from 'unplugin-icons/vite'
import IconsResolver from 'unplugin-icons/resolver'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
import eslintPlugin from 'vite-plugin-eslint'
// 是否自动开启浏览器
const AUTO_OPEN_BROWESR = process.env.AUTO_OPEN_BROWESR
const autoOpenBrowser = AUTO_OPEN_BROWESR === 'true' || AUTO_OPEN_BROWESR === undefined
export default defineConfig({
resolve: {
alias: {
'@': resolve(__dirname, './src'),
'~': resolve(__dirname, './node_modules'),
},
extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json'],
},
plugins: [
vue(),
AutoImport({
imports: ['vue'],
resolvers: [
ElementPlusResolver(),
// 自动导入图标组件
IconsResolver(),
],
eslintrc: {
enabled: true, // Default `false`
filepath: './.eslintrc-auto-import.json', // Default `./.eslintrc-auto-import.json`
globalsPropValue: true, // Default `true`, (true | false | 'readonly' | 'readable' | 'writable' | 'writeable')
},
}),
Components({
resolvers: [
ElementPlusResolver(),
IconsResolver({
enabledCollections: ['ep', 'ant-design'],
customCollections: ['custom'],
}),
],
}),
Icons({
compiler: 'vue3', // 指定编译器
autoInstall: true,
customCollections: {
custom: FileSystemIconLoader('./src/assets/svg'),
},
}),
ElementPlus({
// options,
}),
eslintPlugin({
// 配置选项
cache: false, // 禁用缓存
}),
],
publicDir: 'public',
lintOnSave: true,
server: {
open: autoOpenBrowser ? '/' : '',
host: '127.0.0.1',
port: 3000,
strictPort: false,
https: false, // 开启https
proxy: {},
},
build: {
rollupOptions: {
input: {
main: resolve(__dirname, './index.html'),
},
},
outDir: 'dist',
},
css: {
preprocessorOptions: {
scss: {
additionalData: `@import "@/assets/styles/global.scss";`, // 添加全局样式
},
},
},
})