下面咱们介绍一下该插件的配置项。查看源码咱们会发现以下代码。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// }