William Maio William Maio - 1 month ago 5x
React JSX Question

nwb build-react-app creates root path rather than relative path

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>


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 or null:

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

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