NPM Init Create Package.json
NPM Install--save-dev Html-webpack-plugin
Generate Package.json
{"Name": "Html-webpack-plugin-test", "Version": "1.0.0", "description": "", "Main": "Test.js", "scripts": {"test ":" Echo \ "Error:no test specified\" && exit 1 "}," Author ":" "," License ":" ISC "," devdependencies ": {" H Tml-webpack-plugin ":" ^2.30.1 "}}
Create Test.js
Console.log ("This is just a test ...");
Create Webpack.config.js
var htmlwebpackplugin = require (' Html-webpack-plugin '); var path = require (' path '); var webpackconfig = {entry: './test.js ', Output: {path:path.resolve (__dirname, './dist '), FileName: ' index_bundle.js '},plugins: [New Htmlwebpackplugin ({ Title: "Test File", minify:false})]};module.exports = Webpackconfig;
Execute Webpack--config webpack.config.js
Generate Index.html,index_bundle.js in Dist
Index.html as follows
<! DOCTYPE html>
Webpack Html-webpack-plugin