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

核能气质少年 提交于 2019-12-24 05:56:32

问题


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



来源:https://stackoverflow.com/questions/39441825/nwb-build-react-app-creates-root-path-rather-than-relative-path

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!