-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathvite.config.ts
More file actions
56 lines (54 loc) · 1.6 KB
/
Copy pathvite.config.ts
File metadata and controls
56 lines (54 loc) · 1.6 KB
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
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import dts from 'vite-plugin-dts';
import { resolve } from 'path';
export default defineConfig(({ command }) => {
if (command === 'serve') {
/*
* Dev harness. Content/action APIs are same-origin under /action — set
* VITE_API_PROXY in .env.local to proxy them to a real backend, e.g.
* VITE_API_PROXY=https://dev.sunbirded.org
*/
const apiProxy = process.env.VITE_API_PROXY;
return {
plugins: [react()],
server: {
port: 3002,
proxy: apiProxy
? {
'/action': { target: apiProxy, changeOrigin: true, secure: false },
}
: undefined,
},
};
}
return {
plugins: [
react(),
dts({ include: ['src'], outDir: 'dist', rollupTypes: true }),
],
build: {
lib: {
entry: resolve(__dirname, 'src/index.ts'),
name: 'SunbirdGenericEditor',
formats: ['es', 'umd'],
fileName: (format) => `sunbird-generic-editor.${format}.js`,
},
rollupOptions: {
/* React provided by the host — keep a single React instance. This fork
previews via the legacy ekstep renderer, so no player dependency. */
external: ['react', 'react-dom', 'react/jsx-runtime'],
output: {
globals: {
react: 'React',
'react-dom': 'ReactDOM',
'react/jsx-runtime': 'jsxRuntime',
},
assetFileNames: 'sunbird-generic-editor[extname]',
},
},
sourcemap: true,
cssCodeSplit: false,
},
};
});