Skip to content

Commit d5e96d6

Browse files
committed
chore: try rsbuild and build time performance improvement
1 parent 2a2a395 commit d5e96d6

File tree

1 file changed

+79
-0
lines changed

1 file changed

+79
-0
lines changed

rsbuild.config.ts

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
import { defineConfig } from '@rsbuild/core';
2+
import { pluginReact } from '@rsbuild/plugin-react';
3+
import { pluginSass } from '@rsbuild/plugin-sass';
4+
const path = require('path');
5+
const IS_RELEASE =
6+
process.env.NODE_ENV === 'production' || process.env.NODE_ENV === 'staging' || process.env.NODE_ENV === 'test';
7+
8+
export default defineConfig({
9+
plugins: [
10+
pluginSass({
11+
sassLoaderOptions: {
12+
sourceMap: true,
13+
},
14+
}),
15+
pluginReact(),
16+
],
17+
source: {
18+
entry: {
19+
index: './src/main.tsx',
20+
},
21+
define: {
22+
'process.env': JSON.stringify(process.env),
23+
},
24+
alias: {
25+
react: path.resolve('./node_modules/react'),
26+
'react-dom': path.resolve('./node_modules/react-dom'),
27+
'@/external': path.resolve(__dirname, './src/external'),
28+
'@/components': path.resolve(__dirname, './src/components'),
29+
'@/hooks': path.resolve(__dirname, './src/hooks'),
30+
'@/utils': path.resolve(__dirname, './src/utils'),
31+
'@/constants': path.resolve(__dirname, './src/constants'),
32+
},
33+
},
34+
output: {
35+
copy: [
36+
{
37+
from: 'node_modules/@deriv/deriv-charts/dist/*',
38+
to: 'js/smartcharts/[name][ext]',
39+
globOptions: {
40+
ignore: ['**/*.LICENSE.txt'],
41+
},
42+
},
43+
{ from: 'node_modules/@deriv/deriv-charts/dist/chart/assets/*', to: 'assets/[name][ext]' },
44+
{ from: path.join(__dirname, 'public') },
45+
],
46+
},
47+
tools: {
48+
rspack: {
49+
plugins: [],
50+
resolve: {},
51+
module: {
52+
rules: [
53+
{
54+
test: /\.(s*)css$/,
55+
use: [
56+
{
57+
loader: 'sass-loader',
58+
options: { sourceMap: !IS_RELEASE },
59+
},
60+
{
61+
loader: 'sass-resources-loader',
62+
options: {
63+
resources: require(
64+
path.resolve(__dirname, 'src/components/shared/styles/index.js')
65+
),
66+
},
67+
},
68+
],
69+
},
70+
{
71+
test: /\.xml$/,
72+
exclude: /node_modules/,
73+
use: 'raw-loader',
74+
},
75+
],
76+
},
77+
},
78+
},
79+
});

0 commit comments

Comments
 (0)