【发布时间】: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