-
Notifications
You must be signed in to change notification settings - Fork 59
/
Copy pathvite.config.js
52 lines (52 loc) · 1.72 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
import { fileURLToPath, URL } from 'node:url';
import path from 'path';
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import vueJsx from '@vitejs/plugin-vue-jsx';
import AutoImport from 'unplugin-auto-import/vite';
import Components from 'unplugin-vue-components/vite';
import DefineOptions from 'unplugin-vue-define-options/vite';
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers';
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons';
// https://vitejs.dev/config/
export default defineConfig({
publicDir: 'static',
base: '/admin-web',
server: {
port: 3000,
},
plugins: [
vue(),
vueJsx(),
DefineOptions(),
// 导入svg的
createSvgIconsPlugin({
iconDirs: [path.resolve(process.cwd(), 'src/icons/svg')], // icon存放的目录
symbolId: 'icon-[name]', // symbol的id
inject: 'body-last', // 插入的位置
customDomId: '__svg__icons__dom__', // svg的id
}),
AutoImport({
imports: ['vue', 'vue-router'],
resolvers: [ElementPlusResolver()],
include: [
/\.[tj]sx?$/, // .ts, .tsx, .js, .jsx
/\.vue$/,
/\.vue\?vue/, // .vue
],
dts: 'src/auto-import.d.ts', // 生成的全局变量放到此目录下
eslintrc: { enabled: false }, // 改成true生成一次后禁用即可
}),
Components({
dirs: ['src/components', 'src/layout/components'], // 后面布局组件也有相关的组件期望自动导入
dts: 'src/components.d.ts',
resolvers: [ElementPlusResolver()],
}),
],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)),
},
extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue'],
},
});