问题描述
我正在测试 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 = {网络包:{公共路径:''}}
来源:https://github.com/insin/nwb/blob/master/docs/Configuration.md#publicpath-string
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:
Source: https://github.com/insin/nwb/blob/master/docs/Configuration.md#publicpath-string
这篇关于nwb build-react-app 创建根路径而不是相对路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!