The slowest part of production builds for many apps is minifying. I’ve released version 4 of
zodern:standard-minifier-js to improve this.
Version 4 adds caches so it only minifies files that were modified since the previous production build. One app that had spent 198 seconds minifying now takes 50 seconds during a normal deploy, and another app that had spent 596 seconds now takes 71 seconds.
Besides being fast, the other main feature is creating production source maps. Production source maps can be used with an error tracking service (such as Monti APM, Sentry, or Rollbar) to show better error stack traces. This is unchanged, and works the same as in version 3.
To switch the minifier used by your app, run:
meteor remove standard-minifier-js meteor add zodern:standard-minifier-js meteor add zodern:hide-production-sourcemaps
How much time the cache saves depends on what changed since the last build. For example, after updating npm dependencies used on the client, minifying will take longer during the next production build compared to only modifying app code. If you are deploying from CI, you must configure the CI to cache some of the folders in
.meteor/local. I wrote a general guide here on how to set it up.
Calculating the size of modules for the bundle-visualizer can add up to 30+ seconds to a production build. Since this is unnecessary during a deploy, you can set the environment variable
DISABLE_CLIENT_STATS=true to disable this step. With this set, the improved times above would be an additional 12 - 25 seconds faster.
- Includes all of the improvements in
standard-minifier-jsup to Meteor 1.11
- Compatible with Meteor 1.6 and newer (1.4 - 1.5 were dropped since newer versions of Terser are not compatible)
If anyone who maintains a minifier wants to add caching, you can use the