三行代码  ›  专栏  ›  技术社区  ›  prius

生成react应用程序的意外结果

  •  0
  • prius  · 技术社区  · 3 年前

    我在构建最新版本的React时遇到了问题。 当我运行npm run build时,它会以块的形式构建。

    生成结果:

    File sizes after gzip:
    
      34.45 KB  build/static/js/1.2dd891c4.chunk.js
      763 B     build/static/js/runtime~main.229c360f.js
      711 B     build/static/js/main.f219991b.chunk.js
      509 B     build/static/css/main.ef7da6c0.chunk.css
    

    我没有使用webpack,也没有修改任何内容。我用create react app安装了它。

    {
      "name": "react-test",
      "version": "0.1.0",
      "private": true,
      "dependencies": {
        "react": "^16.6.3",
        "react-dom": "^16.6.3",
        "react-scripts": "2.1.1"
      },
      "scripts": {
        "start": "react-scripts start",
        "build": "react-scripts build",
        "test": "react-scripts test",
        "eject": "react-scripts eject"
      },
      "eslintConfig": {
        "extends": "react-app"
      },
      "browserslist": [
        ">0.2%",
        "not dead",
        "not ie <= 11",
        "not op_mini all"
      ]
    }
    

    如何强制react build以以下格式生成:

      711 B     build/static/js/main.f219991b.js
      509 B     build/static/css/main.ef7da6c0.css
    

    链接到包含生成文件的存储库: https://github.com/Tararan/joes-coffee-store

    0 回复  |  直到 3 年前