-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrsbuild.config.ts
More file actions
114 lines (100 loc) · 3.06 KB
/
Copy pathrsbuild.config.ts
File metadata and controls
114 lines (100 loc) · 3.06 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
import { defineConfig, rspack } from '@rsbuild/core';
import { pluginReact } from '@rsbuild/plugin-react';
import { pluginSass } from '@rsbuild/plugin-sass';
import { pluginSvgr } from '@rsbuild/plugin-svgr';
import { pluginTypeCheck } from '@rsbuild/plugin-type-check';
import chokidar from 'chokidar';
const { convertAllLocales } = require('./src/strings/export');
const serverProxy = {
target: process.env.PUBLIC_TERRAWARE_API,
secure: false,
changeOrigin: false,
xfwd: true,
};
const isDev = process.env.NODE_ENV === 'development';
export default defineConfig({
plugins: [
pluginReact({
reactCompiler: true,
}),
pluginSass(),
pluginSvgr({
mixedImport: true, // Support both default and named imports for SVGs
}),
pluginTypeCheck({ enable: isDev }),
],
source: {
// Entry point
entry: {
index: './src/index.tsx',
},
},
html: {
template: './public/index.html',
favicon: './public/favicon.ico',
},
output: {
// Clean output directory before build
cleanDistPath: true,
// Asset prefix (equivalent to PUBLIC_URL)
assetPrefix: process.env.PUBLIC_URL || '/',
// Generate source maps for easier debugging
sourceMap: true,
},
server: {
host: '0.0.0.0',
htmlFallback: false,
historyApiFallback: true,
proxy: {
'/admin': serverProxy,
'/api': serverProxy,
'/sso': serverProxy,
'/swagger-ui.html': serverProxy,
'/swagger-ui': serverProxy,
'/v3': serverProxy,
},
open: true,
},
dev: {
// CSV file watching with page reload
watchFiles: {
paths: 'src/strings/csv/*.csv',
type: 'reload-page',
},
// Custom middleware for CSV conversion
setupMiddlewares: [
(middlewares) => {
// CSV conversion function
const convert = () => convertAllLocales('src/strings/csv', 'src/strings');
// Watch CSV files and convert on change
// The "add" event is fired when Chokidar first discovers each file,
// which will cause JS to be generated as part of server initialization
chokidar.watch('src/strings/csv/*.csv').on('add', convert).on('change', convert);
return middlewares;
},
],
},
tools: {
rspack: {
plugins: [
// sync-ammo is only needed for playcancas when usePhysics is enabled, but we don't need this and it causes a compilation error, so ignore it
new rspack.IgnorePlugin({ resourceRegExp: /^sync-ammo$/ }),
],
// // TODO handle changes in web-components
// // Snapshot configuration for @terraware/web-components watching
// experiments: {
// cache: {
// type: 'filesystem',
// snapshot: {
// // Watch web-components, but not other modules, for changes
// managedPaths: [/^(.+?[\\/]node_modules[\\/](?!(@terraware[\\/]web-components))(@.+?[\\/])?.+?)[\\/]/],
// },
// },
// },
},
},
performance: {
// Enable build cache for faster rebuilds
buildCache: true,
},
});