-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
54 lines (49 loc) · 1.53 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
import path from 'path';
import { PluginOption, defineConfig, UserConfigExport, loadEnv } from 'vite';
import cssInjectedByJsPlugin from 'vite-plugin-css-injected-by-js';
import pluginReact from '@vitejs/plugin-react';
import eslintPlugin from 'vite-plugin-eslint';
import dts from 'vite-plugin-dts';
const isExternal = (id: string) => !id.startsWith('.') && !path.isAbsolute(id);
export const getBaseConfig = ({ plugins = [] as PluginOption[], lib, additionalConfig = {} as UserConfigExport }) => {
return defineConfig(({ command, mode }) => {
const env = loadEnv(mode, process.cwd(), '');
return {
plugins: [
// Important if using react <18.
// pluginReact({ jsxRuntime: 'classic' }),
pluginReact(),
eslintPlugin({
cache: false,
include: ['./src/components/**/*.ts|tsx'],
exclude: ["/virtual:/", "/node_modules/"],
}),
dts({
insertTypesEntry: true,
include: ['src/components'],
tsConfigFilePath: 'tsconfig-build.json'
}),
cssInjectedByJsPlugin(),
...plugins,
],
build: {
lib,
rollupOptions: {
external: isExternal,
output: {
globals: {
cesium: "Cesium",
react: 'React',
"react-dom": "ReactDOM",
},
},
},
},
define: {
'process.env': env,
'CESIUM_BASE_URL': JSON.stringify(env.CESIUM_BASE_URL)
},
...additionalConfig
}
});
}