-
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathvite.config.js
More file actions
47 lines (45 loc) · 1.29 KB
/
vite.config.js
File metadata and controls
47 lines (45 loc) · 1.29 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
import { defineConfig } from 'vite';
const config = defineConfig({
root: 'demo',
build: {
outDir: 'build'
},
server: {
port: 3456
},
define: {
'process.env': {},
'process.platform': JSON.stringify(process.platform)
},
resolve: {
alias: {
// Replace Lightning CSS with inline stub for browser builds
// Lightning CSS requires Node.js native bindings and cannot run in-browser
'lightningcss': '\0virtual:lightningcss-stub',
// Replace SWC with inline stub for browser builds
// SWC requires Node.js native bindings and cannot run in-browser
'@swc/core': '\0virtual:swc-stub'
}
},
plugins: [{
name: 'native-stub',
resolveId(id) {
if (id === '\0virtual:lightningcss-stub' || id === '\0virtual:swc-stub') {
return id;
}
},
load(id) {
if (id === '\0virtual:lightningcss-stub') {
return `export function transform() {
throw new Error('Lightning CSS is not available in browser environments. CSS minification is disabled in web demo.');
}`;
}
if (id === '\0virtual:swc-stub') {
return `export function minify() {
throw new Error('SWC is not available in browser environments. JavaScript minification uses Terser in web demo.');
}`;
}
}
}]
});
export default config;