5

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.

2 Answers 2

6

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",
Sign up to request clarification or add additional context in comments.

Comments

0

You can add postbuild script in package.json

"scripts": {
    "build": "react-scripts build",
    "postbuild" : "mv build /Player/"
}

Please try this.

1 Comment

The question is about a sub-directory on the web server, not the location of the files on your local computer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.