Use esbuild in your create-react-app.
react-scripts When the project grows, the compilation speed is slow, and the development uses esbuild to improve the compilation speed.
It is recommended to use the development mode to ensure stability !!!
- Relpace
babel-loadertoesbuild-loaderfor faster build time - Relpace
TerserPlugintoESBuildMinifyPluginfor faster build time
npm i react-app-rewired-esbuild -DThis project is based on react-app-rewired.
/* config-overrides.js */
const rewiredEsbuild = require("react-app-rewired-esbuild");
module.exports = function override(config, env) {
// your config ...
return rewiredEsbuild()(config, env);
};
// use `customize-cra`
const { override } = require("customize-cra");
module.exports = override(rewiredEsbuild());specification esbuild-loader
Type: object
Default:
{
loader: useTypeScript ? 'tsx' : 'jsx',
target: 'es2015',
}Type: object
Default:
{
loader: useTypeScript ? 'tsx' : 'jsx',
css: true,
}Type: boolean
Use only for minimizer. It is recommended to add this parameter to the production environment.
Added react introduction in the first line of the error file,Originally, babel-plugin-react-app handled this situation, but esbuild did not.
Originally, create-react-app was compiled with babel, and esbuild would be faster to compile
MIT © fupengl