问题
Is there possibility to override publicPath in react-scripts for dev env. I use symfony and I include react app inside twig so I had to change assets to serve from http://localhost:3000/static/js/bundle.js - this works fine but I have problem with static files because they are rendered in browser as '/static/media/logo.813ua.png' and my current url is http://localhost:8000
What I did is I run yarn eject and modify in webpack.config.dev.js: var publicPath = 'http://localhost:3000/' and everything is working fine but I don't want to eject so is there any possibility to do this without ejecting react-scripts ?
回答1:
Specify your port with with process.env.PORT
(package.json)
"scripts": {
"start": "PORT=1234 react-scripts start"
}
来源:https://stackoverflow.com/questions/43419053/react-react-scripts-publicpath