-
Notifications
You must be signed in to change notification settings - Fork 57
/
vite.config.ts
97 lines (92 loc) · 2.37 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
96
97
import Vue from '@vitejs/plugin-vue'
import ReactivityTransform from '@vue-macros/reactivity-transform/vite'
import type { RollupWarning } from 'rollup'
import AutoImport from 'unplugin-auto-import/vite'
import { TDesignResolver } from 'unplugin-vue-components/resolvers'
import Components from 'unplugin-vue-components/vite'
import VueMacros from 'unplugin-vue-macros/vite'
import { defineConfig } from 'vite'
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
import tsConfigPaths from 'vite-tsconfig-paths'
import pkg from './package.json'
import copyright from './src/utils/copyright'
// Plugin configurations
const vuePlugins = {
VueMacros: VueMacros({
plugins: {
vue: Vue(),
},
}),
AutoImport: AutoImport({
dirs: ['./src/composables'],
imports: ['vue', '@vueuse/core'],
resolvers: [TDesignResolver({ library: 'vue-next', esm: true })],
dts: './types/imports.d.ts',
}),
Components: Components({
directoryAsNamespace: true,
dirs: ['./src/components'],
resolvers: [TDesignResolver({ library: 'vue-next', esm: true })],
dts: './types/components.d.ts',
}),
SvgIcons: createSvgIconsPlugin({
iconDirs: [`${process.cwd()}/src/assets/icons`],
symbolId: 'umo-icon-[name]',
customDomId: 'umo-icons',
}),
}
// Build configuration
const buildConfig = {
lib: {
entry: `${process.cwd()}/src/components/index.ts`,
name: pkg.name,
fileName: 'umo-editor',
},
outDir: 'dist',
copyPublicDir: false,
minify: 'esbuild' as const,
cssMinify: true,
rollupOptions: {
output: [
{
banner: copyright,
intro: `import './style.css'`,
format: 'es' as const,
},
],
external: [
'vue',
...Object.keys(pkg.dependencies ?? {}),
/^@vueuse\/.*/,
/^@tiptap\/.*/,
/^nzh\/.*/,
],
onwarn(warning: RollupWarning, warn: (warning: RollupWarning) => void) {
if (warning.code === 'UNUSED_EXTERNAL_IMPORT') return
warn(warning)
},
},
}
const cssConfig = {
preprocessorOptions: {
less: {
modifyVars: { '@prefix': 'umo' },
javascriptEnabled: true,
},
},
}
export default defineConfig({
base: '/umo-editor',
plugins: [
tsConfigPaths(),
ReactivityTransform(),
...Object.values(vuePlugins),
],
css: cssConfig,
build: buildConfig,
resolve: {
alias: {
'@': `${process.cwd()}/src`,
},
},
})