基于本教程:
using html-webpack-plugin to generate index.html
如果您添加 标题 html-webpack-plugin 选项的选项,如下所示:
new HtmlWebPackPlugin({
template: './src/index.html',
filename: './index.html',
title: 'My App',
}),
并将以下代码段添加到您的 HTML 模板中
<title><%= htmlWebpackPlugin.options.title %></title>
它应该从插件设置中获取标题值并将其显示在标题标签内。
但似乎
<%= htmlWebpackPlugin.options.title %>
不捡值(value)!难道这个特性在 Webpack 4 中被弃用了?
最佳答案
我从 webpack.config.js 中删除了 html-loader。
然后,它就像一个魅力
问候
关于Webpack4 : <%= htmlWebpackPlugin. options.title %> 未取值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51774743/