簡體   English   中英

nwb build-react-app創建根路徑而不是相對路徑

[英]nwb build-react-app creates root path rather than relative path

我正在測試nwb,以使用此示例項目簡化構建React應用程序。 構建應用程序時,index.html中引用的css和js文件的路徑位於根目錄,而不是相對目錄。 有什么辦法可以更改引用?

例如:

在html中,參考如下:

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

代替,

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

您可以在nwb.config.js文件中使用webpack.publicPath為此:

如果要創建與路徑無關的構建,請將publicPath設置為空白:

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

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM