create-webpack-app generates a working webpack setup so you don't have to assemble one by hand. It scaffolds three things: a project, a loader, or a plugin.
It is a separate package from webpack-cli and does not need to be installed — run it through npx and you get the current version.
npx create-webpack-app webpack-demo
cd webpack-demoYou are asked a short series of questions (language, styling, whether to add a dev server) and the answers become a project with a configuration, an entry point, and npm scripts already wired up.
The positional argument is where to generate the project; it defaults to the current directory.
--force accepts the default answer for every question, which is what you want in a script or when you just need a starting point:
npx create-webpack-app ./my-app --force--template picks the framework the project is set up for:
npx create-webpack-app ./my-app --template react| Template | What you get |
|---|---|
default | A plain JavaScript or TypeScript project with CSS and HTML, no framework |
react | A React project |
vue | A Vue project |
svelte | A Svelte project |
Project generation is the init command, which runs by default. These two are equivalent:
npx create-webpack-app ./my-app --template react
npx create-webpack-app init ./my-app --template reactScaffolding is a fine way to start, but it is worth reading Getting Started at least once to understand what the generated configuration actually does. Every project outgrows its template eventually.
npx create-webpack-app loader ./my-loaderThis generates a loader package with the source, a test setup, and an example project you can run against it — the same layout described in Writing a Loader.
npx create-webpack-app plugin ./my-pluginLikewise, this scaffolds a plugin package with its apply method already tapping a compiler hook. Writing a Plugin explains what to do from there.
Both generators accept --template as well, though default is currently the only template for them.
- Getting Started — building the same setup by hand, step by step.
- Writing a Loader and Writing a Plugin.