Skip to content

Upgrade from webpack v1 to v4

Eric Eastwood requested to merge 2078-upgrade-to-webpack-v4 into develop

Upgrade from webpack v1 to v4

Added webpack bundle visual reports (courtesy of webpack-bundle-analyzer)

set WEBPACK_REPORT=1&&npm start
  • router-app:
    • Webpack report: 5.77MB -> 452.15MB
    • gitter.im production: 77KB -> 57.2KB
  • router-chat:
    • Webpack report: 6.21MB -> 665.24MB
    • gitter.im production: 108KB -> 89.2KB
  • vendor:
    • Webpack report: 1.22MB -> 1.77MB
    • gitter.im production: 142KB -> 174KB
Before After
index.html
stats.json
index.html
Previous
  • router-app:
    • Webpack report: 5.77MB -> 427KB
    • gitter.im production: 77KB -> 53.4KB
  • router-chat:
    • Webpack report: 6.21MB -> 662KB
    • gitter.im production: 108KB -> 88.6KB
  • vendor:
    • Webpack report: 1.22MB -> 2.75MB
    • gitter.im production: 142KB -> 290KB
Before After
index.html
stats.json
index.html

Also upgraded the styleguide to webpack v4: https://gitlab.com/gitlab-org/gitter/styleguide/-/merge_requests/25

Dev notes

npm run gulp -- clientapp:compile:webpack

Using a function for webpack splitChunks.cacheGroups.{cacheGroup}.test

optimization: {
  runtimeChunk: 'single',
  splitChunks: {
    maxInitialRequests: 4,
    cacheGroups: {
      default: false,
      vendor: {
        name: 'vendor',
        chunks: 'all',
        // Minimum number of chunks that must share a module before splitting
        minChunks: 2,
        // `d3` is only used by `@gitterhq/cal-heatmap` so let's put it in the specific archive chunk
        test(module, chunks) {
          if (module.nameForCondition) {
            return /[\\/]node_modules[\\/](?!d3)/.test(module.nameForCondition())
          }
        }
      }
    }
  }
},

Todo


Fix https://gitlab.com/gitlab-org/gitter/webapp/issues/2078

Edited by Eric Eastwood

Merge request reports