-
Notifications
You must be signed in to change notification settings - Fork 86
/
vite.coresdk.config.ts
82 lines (80 loc) · 2.29 KB
/
vite.coresdk.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
import { defineConfig } from 'vite';
//@ts-ignore
import path from 'path';
import react from '@vitejs/plugin-react';
import vitePluginImp from 'vite-plugin-imp';
// import mkcert from 'vite-plugin-mkcert';
// import { visualizer } from 'rollup-plugin-visualizer';
//@ts-ignore
const resolve = url => path.resolve(__dirname, url);
// https://vitejs.dev/config/
export default defineConfig({
resolve: {
alias: {
'@components': resolve('./src/components'),
'@server': resolve('./src/server'),
'@core': resolve('./src/pages/editor/core'),
'@options': resolve('./src/pages/editor/components/options/components'),
'@plugins': resolve('./src/pages/editor/plugins'),
'@pages': resolve('./src/pages'),
'@language': resolve('./src/language'),
'@hooks': resolve('./src/hooks'),
'@theme': resolve('./src/theme'),
'@layout': resolve('./src/layout'),
'@stores': resolve('./src/stores'),
'@utils': resolve('./src/utils'),
'@config': resolve('./src/config'),
'@less': resolve('./src/less'),
'@images': resolve('./src/assets/images'),
},
extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json'], // 省略扩展名
},
plugins: [
react({
babel: {
plugins: [
['@babel/plugin-proposal-decorators', { legacy: true }],
['@babel/plugin-proposal-class-properties', { loose: true }],
],
},
}),
vitePluginImp({
libList: [
{
libName: '@icon-park/react',
libDirectory: 'es/icons',
camel2DashComponentName: false,
},
{
libName: 'lodash',
libDirectory: '',
camel2DashComponentName: false,
},
// {
// libName: '@douyinfe/semi-ui',
// },
],
}),
],
define: {
'process.env': process.env,
},
// 入口
publicDir: '/sdk',
build: {
emptyOutDir: false,
outDir: 'dist-sdk', // 指定输出目录
lib: {
//@ts-ignore
entry: path.resolve(__dirname, 'src/pages/editor/core/coresdk.tsx'),
name: 'CoreSDK', // 暴露的全局变量
fileName: format => `coresdk.${format}.js`,
},
rollupOptions: {
output: {
assetFileNames: 'coresdk.[name].[ext]',
},
},
},
base: '/', // 公共基础路径
});