Skip to content
Snippets Groups Projects

Build assets generated by webpack in production mode

Merged Antoine Le Gonidec requested to merge (removed):webpack-switch-to-production into master

Fix #956508 - gitlab: webpack should build assets in production mode
Fix #927297 - gitlab: Update browser cache after upgrade


Issue description is copied from #956508 - gitlab: webpack should build assets in production mode


Current assets building through webpack is done by the following call set in /usr/lib/gitlab/scripts/rake-tasks.sh:

runuser -u ${gitlab_user} -- sh -c 'NODE_OPTIONS="--max-old-space-size=2048" webpack --max-old-space-size=16384 --config config/webpack.config.js'

The issue with this command is that it does not build assets optimized for use in production, making parts of the GitLab interface heavy on bandwidth usage, and slow to use on networks with limited bandwidth.

The suggested replacement should fix this issue by explicitely building assets optimized for production use:

runuser -u ${gitlab_user} -- sh -c 'NODE_ENV="production" NODE_OPTIONS="--max-old-space-size=4096" webpack --config config/webpack.config.js'

The modifications are:

  • Add NODE_ENV="production", this is what triggers the correct assets build mode
  • Replace NODE_OPTIONS="--max-old-space-size=2048" by NODE_OPTIONS="--max-old-space-size=4096", as it seems build in production mode uses more memory (an alternative would be to make the value configurable in /etc/gitlab/gitlab-debian.conf)

Thanks to these tweaks, served assets are much smaller and the overall UI is much more responsive. As an example it takes main.chunk.js from ~25 MB to less than 3MB, before application of gzip compression by nginx.

For a comparison, both of these GitLab instances use the same GitLab version based on buster-fasttrack repositories:

The difference in responsiveness is easily noticeable, and the difference is bandwidth usage is important.

Merge request reports

Merged by Praveen ArimbrathodiyilPraveen Arimbrathodiyil 5 years ago (Apr 12, 2020 12:21pm UTC)

Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
Please register or sign in to reply
Loading