Home  >  Q&A  >  body text

javascript - Final generated jsBundle file compression problem

If you write in the project webpack.config.js

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

The size of the jsBundle file generated by such packaging is 50% smaller, but the problem is that the app cannot load such a jsBundle file. Is there any relevant solution?

迷茫迷茫2663 days ago740

reply all(2)I'll reply

  • 大家讲道理

    大家讲道理2017-07-05 10:56:19

    The compressed jsBundle cannot be loaded because you need to add a banner that weex can recognize
    If you use Vue for development, you need to keep { "framework": "Vue" }
    // code compression plug-in
    The code is as follows

    var optimizePlugin = new webpack.optimize.UglifyJsPlugin({
      compress: {
        warnings: false
      },
      //保留banner
      comments: /{ "framework": "Vue" }/,
      sourceMap: true
    })

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-07-05 10:56:19

    If you use Vue for development, you need to keep { "framework": "Vue" } from being compressed, just like what was said above.

    reply
    0
  • Cancelreply