@@ -4,24 +4,55 @@ const {
44 getBabelLoader,
55 addWebpackPlugin,
66 addWebpackModuleRule,
7- } = require ( 'customize-cra' ) ;
8- const ReactRefreshPlugin = require ( '@pmmmwh/react-refresh-webpack-plugin' ) ;
7+ disableEsLint,
8+ } = require ( "customize-cra" ) ;
9+ const ReactRefreshPlugin = require ( "@pmmmwh/react-refresh-webpack-plugin" ) ;
10+ const { ESBuildPlugin } = require ( "esbuild-loader" ) ;
911
1012module . exports = ( config , env ) => {
11- const prod = config . mode === ' production' ;
13+ const prod = config . mode === " production" ;
1214 const babelLoader = getBabelLoader ( config ) ;
1315
1416 return override (
17+ addWebpackModuleRule ( {
18+ test : / .t s x ? $ / ,
19+ use : [
20+ {
21+ loader : "esbuild-loader" ,
22+ options : {
23+ loader : "tsx" ,
24+ target : "es2015" ,
25+ jsxFactory : "React.createElement" ,
26+ jsxFragment : "React.Fragment" ,
27+ } ,
28+ } ,
29+ ] ,
30+ } ) ,
31+ disableEsLint ( ) ,
32+ addWebpackModuleRule ( {
33+ test : / .j s x ? $ / ,
34+ use : [
35+ {
36+ loader : "esbuild-loader" ,
37+ options : {
38+ loader : "jsx" ,
39+ target : "es2015" ,
40+ jsxFactory : "React.createElement" ,
41+ jsxFragment : "React.Fragment" ,
42+ } ,
43+ } ,
44+ ] ,
45+ } ) ,
1546 // You can choose to just use worker-loader! instead if you want
1647 addWebpackModuleRule ( {
1748 test : / \. w o r k e r \. [ j t ] s x ? $ / ,
1849 use : [
19- { loader : ' worker-loader' } ,
50+ { loader : " worker-loader" } ,
2051 { loader : babelLoader . loader , options : babelLoader . options } ,
2152 ] ,
2253 } ) ,
23-
24- ! prod && addBabelPlugin ( ' react-refresh/babel' ) ,
54+ addWebpackPlugin ( new ESBuildPlugin ( ) ) ,
55+ ! prod && addBabelPlugin ( " react-refresh/babel" ) ,
2556 ! prod && addWebpackPlugin ( new ReactRefreshPlugin ( ) )
2657 ) ( config , env ) ;
2758} ;
0 commit comments