版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/p3118601/article/details/79791329
在 webpack.prod.config.js 文件中
引入
const HtmlWebpackPlugin = require('html-webpack-plugin');
然后
new HtmlWebpackPlugin({ title: '花瓣工作台' + package.version, favicon: './huaban.ico', filename: '../index.html', inject: false })
名称 | 类型 | 默认 | 描述 |
title |
{String} | `` | 用于生成的HTML文档的标题 |
filename |
{String} | 'index.html' | 要写入HTML的文件。默认为index.html 。您可以在这里指定一个子目录太(如:assets/admin.html ) |
template |
{String} | `` | webpack 需要路径到模板。请参阅文档的详细信息 |
templateParameters |
{Boolean\|Object\|Function} | `` | 允许覆盖模板中使用的参数 |
inject |
{Boolean\|String} | true | true \|\| 'head' \|\| 'body' \|\| false 将所有资产注入给定template 或templateContent 。当传递true 或'body' 所有JavaScript资源将被放置在正文元素的底部。'head' 将脚本放置在head元素中 |
favicon |
{String} | `` | 将给定的图标路径添加到输出HTML |
minify |
{Boolean\|Object} | true | 将html-minifier的选项作为对象来缩小输出 |
hash |
{Boolean} | false | 如果true 将webpack 所有包含的脚本和CSS文件附加一个独特的编译哈希。这对缓存清除非常有用 |
cache |
{Boolean} | true | 仅在文件被更改时才发出文件 |
showErrors |
{Boolean} | true | 错误细节将写入HTML页面 |
chunks |
{?} | ? | 允许你只添加一些块(例如只有单元测试块) |
chunksSortMode |
{String\|Function} | auto | 允许控制chunk在被包含到HTML之前应该如何排序。允许的值是'none' \| 'auto' \| 'dependency' \| 'manual' \| {Function} |
excludeChunks |
{String} | `` | 允许你跳过一些块(例如,不要添加单元测试块) |
xhtml |
{Boolean} | false | 如果 现为自动关闭(符合XHTML) |