reactjs - Is there a way to have `react-scripts` include extra files in the root of the build? -


my situation:

i'm hosting app created create-react-app on surge. in order have surge let react-router handle routes, have add 200.html root, , in order handle 404s, have add 404.html root. problem is, npm run build, index.html , favicon.ico added root of build directory.

possible solution:

i can copy other files making build script in package.json react-scripts build && cp 200.html 404.html build.

question:

is there better way have react-scripts add files root of build, rather relying on bash scripting in package.json?

the answer settled on use bash scripts in package.json suspected, decided file operations in deploy script instead of build script, , rename index.html 200.html instead of copying files, as suggested create-react-app docs;

"build": "react-scripts build", "deploy": "npm run build && mv build/index.html build/200.html && surge build mydomain.com" 

i think doing file operation in deploy script, instead of build script, right solution because change unique deployment environment, meaning, if deploying somewhere other surge, might not want rename index file.

still open other solutions if has better suggestion.


Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -