nwb build-react-app creates root path rather than

2020-04-18 05:14发布

问题:

I am testing out nwb to streamline building react apps using this example project. While the app is built, the path of css and js files referenced in index.html are in root rather than relative. Is there any way to change the referencing?

For example:

In the html, the reference are the following,

<script type="text/javascript" src="/vendor.b3f34f12.js"></script>
<script type="text/javascript" src="/app.9b5c57d3.js"></script> 

Instead of,

<script type="text/javascript" src="./vendor.b3f34f12.js"></script>
<script type="text/javascript" src="./app.9b5c57d3.js"></script> 

回答1:

You can use webpack.publicPath in your nwb.config.js file for this:

If you want to create a path-independent build, set publicPath to blank:

module.exports = {
  webpack: {
    publicPath: ''
  }
}

Source: https://github.com/insin/nwb/blob/master/docs/Configuration.md#publicpath-string



标签: reactjs npm nwb