-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvite.config.ts
43 lines (41 loc) · 1.28 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
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import svgr from 'vite-plugin-svgr';
import path from 'path';
import cssInjectedByJsPlugin from 'vite-plugin-css-injected-by-js';
import { env } from 'process';
export default defineConfig(() => {
const alias = {
'@src': path.resolve(__dirname, './src'),
'@common': path.resolve(__dirname, './src/common'),
'@components': path.resolve(__dirname, './src/components'),
'@views': path.resolve(__dirname, './src/views'),
};
// config type "library" is used for building a web-component,
// which is used for the embedded application
return env.npm_config_type === 'library'
? {
plugins: [react(), svgr(), cssInjectedByJsPlugin()],
build: {
lib: {
entry: path.resolve(__dirname, 'src/embed.tsx'),
name: 'linked-data',
formats: ['es', 'umd'],
fileName: format => `linked-data.${format}.js`,
},
},
envPrefix: 'EDITOR_',
resolve: { alias },
define: {
__IS_EMBEDDED_MODE__: true,
},
}
: {
plugins: [react(), svgr()],
envPrefix: 'EDITOR_',
resolve: { alias },
define: {
__IS_EMBEDDED_MODE__: false,
},
};
});