下面咱們介紹一下該插件的配置項。查看源碼咱們會發現以下代碼。javascript
this.options = _.extend({ template: path.join(__dirname, 'default_index.ejs'), templateParameters: templateParametersGenerator, filename: 'index.html', hash: false, inject: true, compile: true, favicon: false, minify: false, cache: true, showErrors: true, chunks: 'all', excludeChunks: [], chunksSortMode: 'auto', meta: {}, title: 'Webpack App', xhtml: false }, options);
簡單介紹一下各個含義html
title:{String} 用來生成頁面的 title 元素 template:{String} 源模板文件 inject:{Boolean|String} 放置js資源。true || 'head' || 'body' || false,若是設置爲 true 或者 body,全部的 javascript 資源將被放置到 body 元素的底部,'head' 將放置到 head 元素中。false則不會引入。 hash:{Boolean} 將添加一個惟一的 webpack 編譯 hash 到全部包含的腳本和 CSS 文件,對於解除 cache 頗有用 favicon:{String} 添加特定的 favicon 路徑到輸出的 HTML 文件中 cache:{Boolean} 只有文件修改後纔會從新打包文件 minify:{Boolean|Object} true if mode is 'production', otherwise false, { collapseWhitespace: true,//是否去除html中的空格、換行符,元素內的不會去除的 removeComments: true,//是否去除html註釋 removeRedundantAttributes: true,// removeScriptTypeAttributes: true,// removeStyleLinkTypeAttributes: true,// useShortDoctype: true// }