31
loading...
This website collects cookies to deliver better user experience
esbuild-loader
offers significant improvements in all these areasI will be using a React boilerplate that uses Webpack and Babel. Feel free to use this on any project of your choice
git clone https://github.com/ReactJSResources/react-webpack-babel.git
cd react-webpack-babel
npm install
npm run build
before adding esbuild-loader
to compare build timeswebpack 5.4.0 compiled successfully in 6127 ms
esbuild-loader
npm i -D esbuild-loader
webpack.config.json
file to replace babel-loader
with esbuild-loader
.You can find this file in the root of your project. For the boilerplate, it's in the config folder. If you are using create-react-app
you will have to eject.
module.exports = {
module: {
rules: [
- {
- test: /\.js$/,
- use: 'babel-loader',
- },
+ {
+ test: /\.js$/,
+ loader: 'esbuild-loader',
+ options: {
+ loader: 'jsx',
+ target: 'es2015'
+ }
+ },
...
],
},
}
ESBuildMinifyPlugin
for a much faster minification process.+ const { ESBuildMinifyPlugin } = require('esbuild-loader')
module.exports = {
...,
+ optimization: {
+ minimizer: [
+ new ESBuildMinifyPlugin({
+ target: 'es2015',
+ css: true
+ })
+ ]
+ },
}
npm run build
to test it againwebpack 5.4.0 compiled successfully in 1904 ms
babel-loader
.esbuild-loader
offers a great way to speed up builds.