forked from Leecason/element-tiptap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
62 lines (60 loc) · 1.55 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
import path from 'path';
import { defineConfig } from 'vite';
import { createVuePlugin } from 'vite-plugin-vue2';
import Components from 'unplugin-vue-components/vite';
function kebabCase(key: string) {
const result = key.replace(/([A-Z])/g, ' $1').trim();
return result
.split(' ')
.join('-')
.toLowerCase();
}
export default defineConfig({
plugins: [
createVuePlugin(),
Components({
resolvers: [{
type: 'component',
resolve: (name: string) => {
if (name.startsWith('El')) {
const compName = name.slice(2);
if (compName !== 'Tiptap') {
const partialName = kebabCase(compName);
if (partialName === 'collapse-transition') {
return {
path: `element-ui/lib/transitions/${partialName}`,
};
}
return {
path: `element-ui/lib/${partialName}`,
sideEffects: [
'element-ui/packages/theme-chalk/src/base.scss',
`element-ui/packages/theme-chalk/src/${partialName}.scss`,
],
};
}
}
},
}],
}),
],
server: {
port: 8080,
},
resolve: {
alias: [
{
find: '@',
replacement: path.resolve(__dirname, 'src'),
},
{
find: 'demos',
replacement: path.resolve(__dirname, 'demos'),
},
{
find: 'element-tiptap',
replacement: path.resolve(__dirname, 'src/index.ts'),
},
],
},
});