【问题标题】:The index html file is not being generated with HtmlWebpackPlugin in Linux在 Linux 中没有使用 HtmlWebpackPlugin 生成索引 html 文件
【发布时间】:2018-06-10 00:54:57
【问题描述】:

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

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',也不会生成。

有什么想法吗?

【问题讨论】:

  • /index. - 你检查过 Ubuntu 上的 root 文件夹吗?因为这对我来说似乎很奇怪。您可以尝试在index 文件之前添加.,例如./index.
  • @TheReason。那是个很好的观点。但是,据我所知,它将被添加到build 路径中。不过,我会试试的
  • @TheReason,实际上,你是对的。现在效果很好。你值得投票:)。请将您的评论作为答案让我选择它

标签: node.js reactjs webpack html-webpack-plugin


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-12-18
    • 1970-01-01
    • 1970-01-01
    • 2015-07-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多