-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
95 lines (93 loc) · 2.29 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
94
95
import * as path from 'path'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
import vueSetupExtend from 'vite-plugin-vue-setup-extend'
// import dts from 'vite-plugin-dts'
import svgLoader from 'vite-svg-loader'
const resolve = p => path.resolve(__dirname, p)
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
vue(),
vueSetupExtend(),
svgLoader(),
// dts({
// insertTypesEntry: true,
// copyDtsFiles: true,
// cleanVueFileName: true
// }),
AutoImport({
// Auto import functions from Element Plus, e.g. ElMessage, ElMessageBox... (with style)
resolvers: [
ElementPlusResolver({
importStyle: 'sass'
})
],
// targets to transform
include: [
/\.[jt]sx?$/, // .ts, .tsx, .js, .jsx
/\.vue$/,
/\.vue\?vue/, // .vue
/\.md$/ // .md
],
// global imports to register
imports: ['vue'],
dts: resolve('typings/auto-imports.d.ts')
}),
Components({
resolvers: [
// Auto register Element Plus components
ElementPlusResolver()
],
dts: resolve('typings/components.d.ts')
})
],
resolve: {
alias: {
'@': resolve('src')
}
},
css: {
//css预处理
preprocessorOptions: {
scss: {
/*
引入var.scss全局预定义变量,
如果引入多个文件,
可以使用
'@import "@/assets/scss/globalVariable1.scss";@import "@/assets/scss/globalVariable2.scss";'
这种格式
*/
additionalData: `@use "@/style/mixin.scss" as *;`
}
}
},
esbuild: {
sourcemap: true
},
build: {
lib: {
entry: resolve('src/index.ts'),
name: 'zhsComponentLibrary',
formats: ['es'],
fileName: () => {
return 'index.js'
}
},
rollupOptions: {
external: ['vue', 'element-plus', 'ant-design-vue'],
// preserveModules: true,
output: {
format: 'es',
globals: {
vue: 'Vue',
'ant-design-vue': 'antDesignVue',
'element-plus': 'elementPlus'
}
}
}
}
})