Linux 中的 HtmlWebpackPlugin 未生成索引 html 文件

The index html file is not being generated with HtmlWebpackPlugin in Linux

我有一个 React 项目,在构建项目时,这个命令 运行s:

new HtmlWebpackPlugin({
  inject: true,
  template: 'public/index.html',
  minify: {
    removeComments: true,
    collapseWhitespace: true,
    removeRedundantAttributes: true,
    useShortDoctype: true,
    removeEmptyAttributes: true,
    removeStyleLinkTypeAttributes: true,
    keepClosingSlash: true,
    minifyJS: true,
    minifyCSS: true,
    minifyURLs: true
  },
  filename: '/index.' + Date.now() + '.html'
}),

当我在 Windows 中构建项目时,它会在文件夹 build 内生成指纹索引文件,如 index.1514560078687.html 以及其他资产和文件。 但是,当我在 Ubuntu 中 运行 它时,它会生成除索引文件之外的所有文件。即使我设置了filename: '/index.html',也不会生成

有什么想法吗?

看起来 HtmlWebpackPluginindex.html 文件存储在您的 root 目录中。你检查过了吗?

尝试在 /index.html 之前添加 . 它可能对您有用。