首页 文章

React - react-scripts publicPath

提问于
浏览
2

是否有可能在dev env的react-scripts中覆盖publicPath . 我使用symfony,我在twig中包含react app,所以我不得不改变资产来从http://localhost:3000/static/js/bundle.js服务 - 这个工作正常但是我有静态文件的问题,因为它们在浏览器中呈现为'/static/media/logo.813ua.png'并且我当前的网址是http://localhost:8000

我做的是我在webpack.config.dev.js中运行纱线弹出和修改:var publicPath ='http://localhost:3000/ ' and everything is working fine but I don' t想要弹出,所以有没有可能在没有弹出react脚本的情况下这样做?

1 回答

  • 0

    使用process.env.PORT(package.json)指定您的端口

    "scripts": {
      "start": "PORT=1234 react-scripts start"
    }
    

相关问题