Webpack4:<%= htmlWebpackPlugin.options.title %> 未获取该值

use*_*537 4 title webpack

基于此教程: 使用 html-webpack-plugin 生成 index.html 如果您向 html-webpack-plugin 选项添加标题选项,如下所示:

new HtmlWebPackPlugin({
  template: './src/index.html',
  filename: './index.html',
  title: 'My App',
}),
Run Code Online (Sandbox Code Playgroud)

并将以下代码段添加到您的 HTML 模板中

<title><%= htmlWebpackPlugin.options.title %></title> 
Run Code Online (Sandbox Code Playgroud)

它应该从插件设置中获取标题值并将其显示在标题标签内。

但好像并<%= htmlWebpackPlugin.options.title %>没有体现出价值!这个功能在 Webpack 4 中是否已被弃用?

Con*_*ong 7

我从 webpack.config.js 中删除了 html-loader。然后,它就像一个魅力问候