代码之家  ›  专栏  ›  技术社区  ›  Gowiem

Docker+React脚本:Slow Bundle.js下载

  •  2
  • Gowiem  · 技术社区  · 6 年前

    在一个小的create-react-app项目中,我在Docker中运行bundle.js文件时遇到了非常糟糕的下载时间。

    什么时候? react-scripts start 在本地运行我看到1.4秒的新编译包下载时间: enter image description here

    当通过Docker Compose运行Docker时,我看到1.4分钟的新编译包下载:

    enter image description here

    需要注意的一点是,在Docker中运行时,编译步骤完成得足够快,但是浏览器中的下载过程非常慢。

    在google上搜索createreact应用程序问题并没有为我提供任何导致这个问题的线索。

    关于我的Docker环境的更多信息--这里是我们的前端服务Docker compose条目:

    frontend:
      environment:
        - CHOKIDAR_USEPOLLING=true
      image: node:8
      volumes:
        - ../frontend:/app
      working_dir: /app
      command: "/bin/sh -c 'npm start'" # This runs `react-script start`
      external_links:
        - api
      ports:
        - "3008:3008"
    

    找地方开始调试这个,因为我的googlefu失败了。

    0 回复  |  直到 6 年前