<bdo id='CtNBa'></bdo><ul id='CtNBa'></ul>

  • <small id='CtNBa'></small><noframes id='CtNBa'>

    1. <i id='CtNBa'><tr id='CtNBa'><dt id='CtNBa'><q id='CtNBa'><span id='CtNBa'><b id='CtNBa'><form id='CtNBa'><ins id='CtNBa'></ins><ul id='CtNBa'></ul><sub id='CtNBa'></sub></form><legend id='CtNBa'></legend><bdo id='CtNBa'><pre id='CtNBa'><center id='CtNBa'></center></pre></bdo></b><th id='CtNBa'></th></span></q></dt></tr></i><div id='CtNBa'><tfoot id='CtNBa'></tfoot><dl id='CtNBa'><fieldset id='CtNBa'></fieldset></dl></div>
      <tfoot id='CtNBa'></tfoot>
    2. <legend id='CtNBa'><style id='CtNBa'><dir id='CtNBa'><q id='CtNBa'></q></dir></style></legend>
      1. React.js app.js 文件大小

        时间:2023-05-28

        <small id='zmMvy'></small><noframes id='zmMvy'>

        <legend id='zmMvy'><style id='zmMvy'><dir id='zmMvy'><q id='zmMvy'></q></dir></style></legend>
            <tbody id='zmMvy'></tbody>

            <tfoot id='zmMvy'></tfoot>
            • <bdo id='zmMvy'></bdo><ul id='zmMvy'></ul>
                • <i id='zmMvy'><tr id='zmMvy'><dt id='zmMvy'><q id='zmMvy'><span id='zmMvy'><b id='zmMvy'><form id='zmMvy'><ins id='zmMvy'></ins><ul id='zmMvy'></ul><sub id='zmMvy'></sub></form><legend id='zmMvy'></legend><bdo id='zmMvy'><pre id='zmMvy'><center id='zmMvy'></center></pre></bdo></b><th id='zmMvy'></th></span></q></dt></tr></i><div id='zmMvy'><tfoot id='zmMvy'></tfoot><dl id='zmMvy'><fieldset id='zmMvy'></fieldset></dl></div>

                  本文介绍了React.js app.js 文件大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我创建了包含 7 个页面和 13 个组件的非常简单的 react 应用程序.我正在使用 gulp 编译它,browserify 用于依赖项,所有文件都被最小化.

                  I created pretty simple react application containing 7 pages and 13 components. I am using gulp to compile it, browserify for dependencies, all files are minimized.

                  我构建的 app.js 文件有 1.1 MB.我觉得挺大的.

                  My build'ed app.js file has 1.1 MB. I think it is quite big.

                  我能做些什么来减小它的大小?有没有什么好的做法可以实现最小尺寸?

                  What can I do to reduce its size ? Are there any good practices to achieve smallest size ?

                  我没有依赖的源代码是91 KB.

                  My source code without dependencies is 91 KB.

                  推荐答案

                  使用 webpack-uglify 并禁用 source maps 可以极大地提高输出到合理的大小(对于 hello world 应用程序约为 140kbs)

                  Using webpack-uglify and disabling source maps can greatly improve the output to a reasonable size (~140kbs for a hello world application)

                  几个步骤:

                  将 webpack 配置中的 devtool 设置为 cheap-source-mapcheap-module-source-map 以便不捆绑源映射输出:

                  Setting devtool in webpack config to cheap-source-map or cheap-module-source-map so the source maps are not bundled with the output:

                  {
                    eval: 'cheap-source-map'
                  }
                  

                  激活 uglify 插件或使用 -p 参数调用 webpack

                  Activate uglify plugin or call webpack with -p argument

                  plugins: [
                    new webpack.optimize.UglifyJsPlugin({
                      compress: {
                        warnings: false
                      }
                    })
                  ]
                  

                  为生产定义节点环境导致 webpack 删除测试助手并优化输出大小:

                  Defining node environment for production causes webpack to remove test helpers and optimize the ouput size:

                  plugins: [
                    new webpack.DefinePlugin({
                      'process.env': {
                        'NODE_ENV': JSON.stringify('production')
                      },
                    })
                  ]
                  

                  注意:这些步骤应仅用于生产构建,因为它们会增加构建时间.

                  Note: these steps should be only used for production builds as they increase the build time.

                  资源:https://medium.com/modus-create-front-end-development/optimizing-webpack-production-build-for-react-es6-apps-a637e5692aea#.bug2p64de

                  这篇关于React.js app.js 文件大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:Nodemon监视选项损坏 下一篇:我可以将 gulp livereload 设置为在所有文件编译后运

                  相关文章

                  最新文章

                    <legend id='mpyaz'><style id='mpyaz'><dir id='mpyaz'><q id='mpyaz'></q></dir></style></legend>
                      <bdo id='mpyaz'></bdo><ul id='mpyaz'></ul>
                    <tfoot id='mpyaz'></tfoot>

                      <small id='mpyaz'></small><noframes id='mpyaz'>

                      <i id='mpyaz'><tr id='mpyaz'><dt id='mpyaz'><q id='mpyaz'><span id='mpyaz'><b id='mpyaz'><form id='mpyaz'><ins id='mpyaz'></ins><ul id='mpyaz'></ul><sub id='mpyaz'></sub></form><legend id='mpyaz'></legend><bdo id='mpyaz'><pre id='mpyaz'><center id='mpyaz'></center></pre></bdo></b><th id='mpyaz'></th></span></q></dt></tr></i><div id='mpyaz'><tfoot id='mpyaz'></tfoot><dl id='mpyaz'><fieldset id='mpyaz'></fieldset></dl></div>