Nrwl Nx React 在构建index.html 中自定义静态路径

问题描述 投票:0回答:2

如何将

/myBundleFile.js
中的脚本 src 中的捆绑文件路径从
/static/myBundleFile.js
更改为
index.html
,这是我通过使用 Nx 构建 React 项目获得的?

我正在使用 Nrwl Nx 的默认 React 插件。

javascript reactjs nrwl-nx
2个回答
0
投票

您需要在该项目的

deployUrl
中使用
project.json
属性。

https://nx.dev/packages/web/executors/webpack#deployurl


0
投票

您可以通过将

output.fileName
output.chunkFilename
添加到应用程序的
webpack.config.js
来实现这一点,如下所示:

module.exports = {
  output: {
    // ...
    filename: 'static/[name].[contenthash:20].js',
    chunkFilename: 'static/[name].[contenthash:20].chunk.js',
  },
  // ...
}
© www.soinside.com 2019 - 2024. All rights reserved.