1. 程式人生 > >webpack 效率及性能提升

webpack 效率及性能提升

IT 但是 aof res 時間 thread html 應該 加速

1.//比UglifyJsPlugin壓縮給力1倍的壓縮工具

var ParallelUglifyPlugin = require(‘webpack-parallel-uglify-plugin‘)

   new ParallelUglifyPlugin({
      cacheDir: ‘.cache/‘,
      uglifyJS: {
        output: {
          comments: false
        },
        compress: {
          warnings: false
        }
      }
    }),

2.  

/*
*myhappy的加速度並不顯著,可能需要電腦配置.但是命中cache後速度會翻倍.
*主要的時間消耗是在js的轉換上,就是babel-loader js,大概要23秒.
*壓縮時間大概是10秒.

*https://github.com/amireh/happypack

*http://taobaofed.org/blog/2016/12/08/happypack-source-code-analysis/
*/

var myHappyPack = new HappyPack({
  loaders: [{
    // id: ‘js‘,
    loader: ‘babel-loader‘,
    threadPool: happyThreadPool,
    options: {
      cacheDirectory: 
true, } }] })

然後加入到plugins:[]裏

3.推薦的tool,效率與實用平衡考慮

//http://www.cnblogs.com/imwtr/p/7801973.html

devtool: isdev ? "cheap-module-eval-source-map" : "cheap-source-map",

4.如果用到將公用js 合並 至 CommonsChunkPlugin ,則開發環境的vendor引用應該放在最前面,否則會報webpackjsonp錯誤.

webpack 效率及性能提升