This repo is a collection of simple demos of Webpack.
These demos are purposely written in a simple and clear style. You will find no difficulty in following them to learn the powerful tool.
First, install Webpack and webpack-dev-server globally.
$ npm i -g webpack webpack-cli webpack-dev-serverThen, clone the repo.
$ git clone https://github.com/HelloWoed/webpack-project-demo.gitInstall the dependencies.
$ cd webpack-project-demo
$ npm installNow, play with the source files under the repo's demo* directories.
$ cd demo01
$ npm run build
$ npm run devIf the above command doesn't open your browser automaticly, you have to visit http://127.0.0.1:9000 by yourself.
After having webpack.config.js, you can invoke Webpack without any arguments.
$ webpackSome command-line options you should know.
webpack– building for developmentwebpack -p– building for production (minification)webpack --watch– for continuous incremental buildingwebpack -d– including source mapswebpack --colors– making building output pretty
You could customize scripts field in your package.json file as following.
// package.json
{
// ...
"scripts": {
"build": "webpack --mode production --watch --progress --display-reasons --color",
"dev": "webpack-dev-server --inline --progress --mode development"
}
// ...
}