1、改進
- 持久化緩存
- 更好的算法和默認值改進長期緩存
- 更好的tree shaking
特色
- webpack 5 會移除全部廢棄的特性。爲了無障礙的推動,應保證在構建時再無任何的廢棄警告。
- mode 必須
webpack4=>5
- node.js 10.13
- webpack-cli升級到最新
- plugin 和 loader 升級到最新的可用版本
升級廢棄的配置項
- optimization.hashedModuleIds: true ↦ optimization.moduleIds: 'hashed'
- optimization.namedChunks: true ↦ optimization.chunkIds: 'named'
- optimization.namedModules: true ↦ optimization.moduleIds: 'named'
- NamedModulesPlugin ↦ optimization.moduleIds: 'named'
- NamedChunksPlugin ↦ optimization.chunkIds: 'named'
- HashedModulesPlugin ↦ optimization.moduleIds: 'hashed'
- optimization.noEmitOnErrors: false ↦ optimization.emitOnErrors: true
- optimization.occurrenceOrder: true ↦ optimization: { chunkIds: 'total-size', moduleIds: 'size' }
- optimization.splitChunks.cacheGroups.vendors ↦ optimization.splitChunks.cacheGroups.defaultVendors
- Compilation.entries ↦ Compilation.entryDependencies
- serve ↦ serve 已被移除,推薦使用 DevServer
兼容性
node: {
Buffer: false,
process: false
}