forked from imzbf/md-editor-rt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
74 lines (71 loc) · 1.93 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
import path from 'path';
import { UserConfigExport, ConfigEnv } from 'vite';
import reactRefresh from '@vitejs/plugin-react-refresh';
import nodeService from './vitePlugins/nodeService';
import markdownImport from './vitePlugins/markdownImport';
import dts from 'vite-plugin-dts';
// https://vitejs.dev/config/
export default ({ mode }: ConfigEnv): UserConfigExport => {
console.log('mode:', mode);
return {
base: '/',
publicDir: mode === 'production' ? false : './dev/public',
server: {
host: 'localhost',
open: true,
port: 2233,
https: false
},
resolve: {
alias: {
// 键必须以斜线开始和结束
'@': path.resolve(__dirname, './dev')
}
},
plugins: [
mode !== 'production' && nodeService(),
mode !== 'production' && markdownImport(),
mode !== 'production' && reactRefresh(),
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'
? {
outDir: path.resolve(__dirname, 'lib'),
lib: {
entry: path.resolve(__dirname, './MdEditor/Editor.tsx'),
name: 'MdEditorRT',
formats: ['es']
// fileName: (): string => 'md-editor-rt.js'
},
rollupOptions: {
external: ['react'],
output: {
globals: {
react: 'React'
}
}
}
}
: {}
};
};