【问题标题】:React - react-scripts publicPathReact - 反应脚本 publicPath
【发布时间】:2017-04-14 20:49:45
【问题描述】:

是否有可能覆盖开发环境的 react-scripts 中的 publicPath。我使用 symfony 并在 twig 中包含 react 应用程序,因此我必须更改资产以从 http://localhost:3000/static/js/bundle.js 提供服务 - 这工作正常,但我对静态文件有问题,因为它们在浏览器中呈现为 '/static/media/logo.813ua。 png',我当前的网址是http://localhost:8000

我所做的是我在 webpack.config.dev.js: var publicPath = 'http://localhost:3000/' 中运行 yarn 弹出和修改,一切正常,但我不想弹出,所以有没有可能做这没有弹出反应脚本?

【问题讨论】:

  • 是的,在你的 package.json 中,"start": "PORT=8000 react-scripts start"

标签: javascript reactjs webpack react-redux webpack-dev-server


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-20
    • 2019-08-07
    • 2019-09-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多