@@ -4,24 +4,44 @@ const {
44 getBabelLoader,
55 addWebpackPlugin,
66 addWebpackModuleRule,
7- } = require ( 'customize-cra' ) ;
8- const ReactRefreshPlugin = require ( '@pmmmwh/react-refresh-webpack-plugin' ) ;
7+ } = require ( "customize-cra" ) ;
8+ const ReactRefreshPlugin = require ( "@pmmmwh/react-refresh-webpack-plugin" ) ;
9+ const { ESBuildPlugin } = require ( "esbuild-loader" ) ;
910
1011module . exports = ( config , env ) => {
11- const prod = config . mode === ' production' ;
12+ const prod = config . mode === " production" ;
1213 const babelLoader = getBabelLoader ( config ) ;
1314
1415 return override (
16+ addWebpackModuleRule ( {
17+ test : / .t s x ? $ / ,
18+ use : [
19+ {
20+ loader : "esbuild-loader" ,
21+ options : { loader : "tsx" , target : "es2015" } ,
22+ } ,
23+ ] ,
24+ } ) ,
25+
26+ addWebpackModuleRule ( {
27+ test : / .j s x ? $ / ,
28+ use : [
29+ {
30+ loader : "esbuild-loader" ,
31+ options : { loader : "jsx" , target : "es2015" } ,
32+ } ,
33+ ] ,
34+ } ) ,
1535 // You can choose to just use worker-loader! instead if you want
1636 addWebpackModuleRule ( {
1737 test : / \. w o r k e r \. [ j t ] s x ? $ / ,
1838 use : [
19- { loader : ' worker-loader' } ,
39+ { loader : " worker-loader" } ,
2040 { loader : babelLoader . loader , options : babelLoader . options } ,
2141 ] ,
2242 } ) ,
23-
24- ! prod && addBabelPlugin ( ' react-refresh/babel' ) ,
43+ addWebpackPlugin ( new ESBuildPlugin ( ) ) ,
44+ ! prod && addBabelPlugin ( " react-refresh/babel" ) ,
2545 ! prod && addWebpackPlugin ( new ReactRefreshPlugin ( ) )
2646 ) ( config , env ) ;
2747} ;
0 commit comments