Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

react-scripts build into a subdirectory

Tags:

I am using create-react-app and running react-scripts build on a my project, but I'm having an issue with the build output. I need the build output to go in a subdirectory of the build folder like shown here

Build
-- Player 

And I need the Urls for the generated for the JS and CSS files as shown here to include the Player in the path. I need these.

<link href="/static/css/main.02096f02.css" rel="stylesheet">
<script type="text/javascript" src="/static/js/main.75412701.js"></script>

to be these

<link href="/player/static/css/main.02096f02.css" rel="stylesheet">
<script type="text/javascript" src="/player/static/js/main.75412701.js"></script>

I need this to automate my build and deployment. Otherwise the default scripts work perfectly.

like image 882
Danny Ellis Jr. Avatar asked Mar 06 '18 15:03

Danny Ellis Jr.


1 Answers

If you set the homepage attribute in your package.json file, that will modify all the links generated in /build/index.html. Here's the docs.

"homepage": "http://mywebsite.com/relativepath",
like image 152
carpiediem Avatar answered Oct 11 '22 10:10

carpiediem