Webpack Config Generator
Configure entry, output, loaders, plugins, and devServer options visually — get a ready-to-use webpack.config.js with the matching install command.
Build Mode
development
production
none
Entry & Output
Source Maps
Loaders
Plugins
Dev Server
Enable webpack-dev-server
Port
Optimization
Tree shaking is automatic in production mode when you use ES module
import/export syntax — no plugin needed.webpack.config.js
const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const webpack = require('webpack')
module.exports = {
mode: 'production',
entry: './src/index.js',
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].[contenthash].js',
clean: true,
},
devtool: 'source-map',
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env', '@babel/preset-react'],
},
},
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader'],
},
{
test: /\.(png|jpg|jpeg|gif|svg|webp)$/i,
type: 'asset/resource',
},
{
test: /\.(woff|woff2|eot|ttf|otf)$/i,
type: 'asset/resource',
},
],
},
resolve: {
extensions: ['.js', '.jsx', '.json'],
},
plugins: [
new HtmlWebpackPlugin({
template: './public/index.html',
filename: 'index.html',
}),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'production'),
}),
],
optimization: {
minimize: true,
},
devServer: {
port: 3000,
hot: true,
open: false,
historyApiFallback: true,
static: {
directory: path.join(__dirname, 'public'),
},
compress: true,
},
}Required packages
npm install
npm install --save-dev webpack webpack-cli babel-loader @babel/core @babel/preset-env @babel/preset-react css-loader style-loader html-webpack-plugin webpack-dev-server