score:1

Accepted answer

I've made a new repository but I still want to serve the create-react-app with express so I've followed this tutorial and created a /client folder in my project and put there all the create-react-app files and folders together with its package.json.

The scripts I use to deploy or lunch in dev mode are the following:

"client": "cd client && yarn start",
"server": "nodemon server.js",
"dev": "concurrently --kill-others-on-fail \"yarn server\" \"yarn client\"",
"build": "yarn && cd client && yarn && yarn build && cd ../",
"deploy": "git pull origin master && yarn build && pm2 restart server.js || pm2 start server.js"

I'd like to know which are the cons of this approach if someone has any experience.

score:0

First, eject your create-react-app project like this :

npm run eject or yarn eject

Second, you can configure index.html and public folder path from: [react-project-dir]/config/paths.js

In your case i assume eject command will create a folder in root directory of your project so you can find it in: [project-dir]/config/paths.js

You can change these parameters:

... appPublic: resolveApp('public'), appHtml: resolveApp('public/index.html'),

like this:

appPublic: resolveApp('public_react'), appHtml: resolveApp('public_react/index.html'),


Related Query

More Query from same tag