开发中需要在“ / static”之前附加一个子目录

问题描述 投票:1回答:1

显然,我不断遇到的解决方案是针对生产而非开发的,因此它们不起作用。

这些解决方案包括以下任何数目:

index.html

<base href="/client">

。env

PUBLIC_URL="/client"

package.json

"homepage": "/client"

or 

"homepage: "http://localhost/client"

App.js

<BrowserRouter
  basename='/client'>
  <>
    <Route exact path='/' component={Test} />
  </>
</BrowserRouter>

这些都不是解决我要完成的任务的工作:我需要资产的URL为/client/static,而不是/static。后者使该应用程序在我的开发环境中根本无法呈现。

我现在基本上正在开发中,路由应该如下所示:

/       = general landing page
/client = route for client login
/admin  = route for internal admin login
/api    = route for server that the /client and /admin communicate with

似乎是应该很容易实现的东西,但是失败了,因为所提出的解决方案似乎都无法在开发中使用。例如,根据Node和/或React文档,PUBLIC_URL在开发中将被忽略。

这里的解决方案是什么?

回购演示该问题:

https://github.com/eox-dev/subdir-issue

node.js reactjs react-router-dom
1个回答
0
投票
© www.soinside.com 2019 - 2024. All rights reserved.