Create react app, build with relative directories

2019-08-23 11:27发布

问题:

In my CRA when I do an "npm run build" it creates a bundle file index.html that has links that look like:

link href="/static/css/main.ef6ca77b.css"

But I don't want it to refer to absolute directories. I'd like for it to use relative directories like:

link href="static/css/main.ef6ca77b.css"

(so without that initial slash...)

Is this possible? The reason I'm asking is I'm deploying multiple apps to a directory and they need refer to their resources relatively and not absolutely...

回答1:

Had to add:

 "homepage": "./"

to package.json