Closed mrbone closed 6 years ago
提高 webpack build 时间的方式有几种
减少需要使用 loaders 的文件数量
{ test: /\.js$/, + include: path.resolve(__dirname, "src"), loader: "babel-loader" }
plugin/loader 都有启动时间,所以使用的越少越好。
减少检索文件的数量同样可以提高速度。如下的方式都可以:
resolve.modules, resolve.extensions, resolve.mainFiles, resolve.descriptionFiles
resolve.symlinks: false
resolve.cacheWithContext: false
使用 DllPlugin 让不常变化的 module 走单独的构建。
使用 cache-loader
关闭 soucemap
尽量少使用 presets/plugins
ts-loader
happyPackMode: true
transpileOnly: true
官网
提高 webpack build 时间的方式有几种
loaders
减少需要使用 loaders 的文件数量
Bootstrap
plugin/loader 都有启动时间,所以使用的越少越好。
Resolve
减少检索文件的数量同样可以提高速度。如下的方式都可以:
resolve.modules, resolve.extensions, resolve.mainFiles, resolve.descriptionFiles
的数量。resolve.symlinks: false
resolve.cacheWithContext: false
Dlls
使用 DllPlugin 让不常变化的 module 走单独的构建。
chunk 越小越好
Worker Pool
缓存持久化
使用 cache-loader
Production 建议
SourceMap
关闭 soucemap
特殊工具的
Babel
尽量少使用 presets/plugins
Ts
ts-loader
下开启happyPackMode: true
/transpileOnly: true
参考资料
官网