-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.js
More file actions
79 lines (73 loc) · 1.89 KB
/
vite.config.js
File metadata and controls
79 lines (73 loc) · 1.89 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import { resolve } from 'path';
// https://vitejs.dev/config/
export default defineConfig(({ command, mode }) => {
// Check if we're building demos
const isDemoBuild = process.env.BUILD_DEMOS === 'true';
// Check if we're building full CSS
const isFullCssBuild = process.env.BUILD_FULL_CSS === 'true';
if (isDemoBuild) {
// Demo build configuration - includes all dependencies
return {
plugins: [react()],
base: './',
build: {
outDir: 'dist-demos',
rollupOptions: {
input: {
main: resolve(__dirname, 'index.html'),
},
},
},
};
}
const rollupOptions = {
output: {
assetFileNames: 'index.css',
},
external: [
'react',
'react-dom',
'react/jsx-runtime',
'react/jsx-dev-runtime',
],
};
const rollupOptionsStrict = {
...rollupOptions,
external: [
...rollupOptions.external,
/^@wx\//, // matches all modules starting with "@svar-ui/"
/^@svar-ui\//, // matches all modules starting with "@svar-ui/"
],
};
if (isFullCssBuild) {
// Full CSS build configuration - includes base styles and component styles
return {
plugins: [react()],
build: {
outDir: 'dist-full',
lib: {
entry: resolve(__dirname, 'src/full-css.js'),
fileName: 'index',
formats: ['es'],
},
rollupOptions,
},
};
}
// Library build configuration (original)
return {
plugins: [react()],
build: {
sourcemap: true,
lib: {
//eslint-disable-next-line no-undef
entry: resolve(__dirname, 'src/index.js'),
fileName: (format) => (format === 'cjs' ? 'index.cjs' : 'index.es.js'),
formats: ['es', 'cjs'],
},
rollupOptions: rollupOptionsStrict,
},
};
});