forked from imzbf/md-editor-v3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
72 lines (68 loc) · 1.69 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
import path from 'path';
import { UserConfigExport, ConfigEnv } from 'vite';
import vue from '@vitejs/plugin-vue';
import vueJsx from '@vitejs/plugin-vue-jsx';
import nodeService from './vitePlugins/nodeService';
import markdownImport from './vitePlugins/markdownImport';
// https://segmentfault.com/a/1190000040127796
import dts from 'vite-plugin-dts';
const libBuildOptions = {
outDir: path.resolve(__dirname, 'lib'),
lib: {
entry: path.resolve(__dirname, './MdEditor'),
name: 'MdEditorV3'
},
rollupOptions: {
external: ['vue'],
output: {
globals: {
vue: 'Vue'
}
}
}
};
export default ({ mode }: ConfigEnv): UserConfigExport => {
console.log('mode:', mode);
return {
base: '/',
publicDir: mode === 'production' ? false : './dev/public',
server: {
host: 'localhost',
open: true,
port: 3344,
https: false
},
resolve: {
alias: {
'@': path.resolve(__dirname, './dev')
}
},
plugins: [
vue(),
vueJsx(),
mode !== 'production' && nodeService(),
mode !== 'production' && markdownImport(),
mode === 'production' &&
dts({
include: [
'./MdEditor/type.ts',
'./MdEditor/Editor.tsx',
'./MdEditor/extensions/**/*.tsx',
'./MdEditor/index.ts',
'./MdEditor/config.ts'
]
})
],
css: {
modules: {
localsConvention: 'camelCase' // 默认只支持驼峰,修改为同事支持横线和驼峰
},
preprocessorOptions: {
less: {
javascriptEnabled: true
}
}
},
build: mode === 'production' ? libBuildOptions : {}
};
};