1001Ferramentas
📦Dev

Webpack Config Generator

Generate a minimal webpack.config.js.


  

The minimum webpack skeleton that builds

Webpack does nothing useful until a webpack.config.js exists, and the official docs open with concepts when all you wanted was a skeleton to adapt. The predictable outcome: you copy a snippet from a 2019 blog post, it uses an option that was renamed in version 5, and the build dies with a message that points nowhere useful.

What comes out is the functional minimum: entry at src/index.js, output to dist/bundle.js built with path.resolve, mode production and two loader rules. One sends .js files outside node_modules through babel-loader, the other runs .css through css-loader and style-loader. That pair is applied right to left, and swapping the order breaks the build. There are no fields to edit; the button always returns the same text.

Before running it, install webpack, webpack-cli, babel-loader with @babel/core and @babel/preset-env, plus style-loader and css-loader, and add a babel.config.js. Production mode already enables minification and tree shaking; for local work switch to development and add devtool source-map. Missing here are devServer and HtmlWebpackPlugin, which most real projects end up wanting. Generation runs in the browser.

Frequently asked questions

Why is my CSS missing from the bundle?
Check the order inside use. css-loader interprets the file and style-loader injects the tag, and webpack applies the array from right to left. Also make sure the CSS is imported by a JS file reachable from the entry.
Do I still need webpack?
Not always. For a fresh app, Vite or esbuild take less setup. Webpack still earns its place in legacy codebases, in very specific loader pipelines, or when the team already maintains custom plugins.
How do I get a development build?
Set mode to development, add devtool source-map and run webpack --watch. For automatic browser reloads, install webpack-dev-server and add a devServer section.

Related Tools