webpack4升5

  • yarn add webpack@next -D

一、改进

  • 持久化缓存
  • 更好的算法和默认值改进长期缓存
  • 更好的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
  }

你可能感兴趣的:(webpack)