-
Create application directory for webpack project.
mkdir app && cd app
-
Install dependent node modules
npm init --yes npm install webpack webpack-dev-server html-webpack-plugin --save-dev
-
Create a sample javascript file(
app.js
)document.write('<h1>Hello World!</h1>');
-
Create a sample webpack configuration file(
webpack.config.js
)var HtmlWebpackPlugin = require('html-webpack-plugin'); module.exports = { entry: './app.js', output: { path: (__dirname + '/.build'), filename: 'app.js' }, plugins: [ new HtmlWebpackPlugin() ] };
-
Run Webpack dev server
./node_modules/.bin/webpack-dev-server --open --inline
-
Open the application http://localhost:8080/