Skip to content

Option to compile webpack once

Lukas Eipert requested to merge leipert-webpack-single-compile into master

Currently during development we start the webpack dev server in order to serve compiled assets, watch for changes in the source and recompiling. This enables frontend developers to see changes they make quickly.

This however consumes a lot of memory, as all files are kept in memory. For developers who are not interested in having these features, this memory is just wasted.

This extends our webpack asset logic a bit.

Per default, the webpack-dev-server will behave like it does currently.

If you set the environment variable DEV_SERVER_STATIC=true, the following will be done:

  1. webpack compiles the assets and saves them at public/assets
  2. a simple ruby http static file server will serve them like webpack-dev-server and integrate with webpack-rails
  3. nodemon (our process monitoring) will watch (ee/)?app/assets/javascripts for changes and go to step 1 if some happen, for example when changing or pulling the branch.

The first step will consume a lot of memory for a few seconds (around 20 currently), but then the static file server consumes way less. So unless you change JavaScript files, this should improve memory consumption by at least 800 MegaBytes.

Merge request reports