60.htmlwebpackplugin plug-in configuration-title use, modify the Webpack.config.js file, modify the contents as follows
var webpack = require (' Webpack '), var htmlwebpackplugin = require (' Html-webpack-plugin '); module.exports = {entry: __ DirName + "/app/greeter.js", Output: {path: __dirname + "/build", FileName: "Bundle.js"},devserver:{contentbase: "./ Public ", Historyapifallback:true,inline:true},module:{loaders:[{test:/\.json$/,loader:" Json-loader "},{test:/\. Js$/,exclude:/node_modules/,loader: ' Babel-loader '},{test:/\.css$/,loader: ' Style-loader!css-loader?modules '}], Plugins:[new Webpack. Bannerplugin ("Copyright Suyan"), new Htmlwebpackplugin ({template:__dirname + "/app/index.tmpl.html", Title: ' Htmlwebpackplugin title Test '}]}
Description
Template: Represents the title of the generated HTML document, configures the item, does not replace the contents of the title element in the specified template file, and uses the template engine syntax in the HTML template file to obtain the configuration item value.
61. Create the template file index.tmpl.html, the template content is as follows
<! DOCTYPE html>
62. Packaging using the Webpack command in a command-line program650) this.width=650; "Src=" https://s5.51cto.com/wyfs02/M01/8D/C1/wKiom1iqSqnzJ-yJAABWSvM61Ec462.png-wh_500x0-wm_ 3-wmp_4-s_1655530827.png "title=" 62.png "alt=" Wkiom1iqsqnzj-yjaabwsvm61ec462.png-wh_50 "/>
63. Look at the directory structure under the build directory, generate a file called index.html, the project directory structure is as follows, the index.html file contents are as follows:650) this.width=650; "Src=" https://s1.51cto.com/wyfs02/M02/8D/C1/wKiom1iqSx_B0Zc0AAAj0rGwRGI888.png-wh_500x0-wm_ 3-wmp_4-s_2450212701.png "title=" 63-1.png "alt=" Wkiom1iqsx_b0zc0aaaj0rgwrgi888.png-wh_50 "/>
<! DOCTYPE html>
DescriptionIndex.html file is generated through our template file index.tmpl.html, in our Webpack.config.js file, we used the Htmlwebpackplugin plugin, in the plug-in configuration item we configured the title: ' Htmlwebpackplugin title test ', and then look at the <title> of our generated index.html file the contents of this tag are exactly what we configured in Webpack.config.js. In the template file we used the <%=htmlwebpackplugin.options.title%> to get the title value in the configuration file.
This article is from the "Yan" blog, please be sure to keep this source http://suyanzhu.blog.51cto.com/8050189/1899356
Webpack Getting Started tutorial Xi.