diff --git a/Gruntfile.js b/Gruntfile.js index c97795e743..9a84c15aa0 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -8,6 +8,8 @@ var initWorker; var incomplete = []; var running = 0; +env.NODE_ENV = env.NODE_ENV || 'development'; + module.exports = function (grunt) { var args = []; var initArgs = ['--build']; diff --git a/src/meta/build.js b/src/meta/build.js index cc3321923f..290957512a 100644 --- a/src/meta/build.js +++ b/src/meta/build.js @@ -180,6 +180,11 @@ function build(targets, callback) { async.series([ beforeBuild, function (next) { + var threads = parseInt(nconf.get('threads'), 10); + if (threads) { + require('./minifier').maxThreads = threads - 1; + } + var parallel = !nconf.get('series'); if (parallel) { winston.info('[build] Building in parallel mode'); diff --git a/src/meta/minifier.js b/src/meta/minifier.js index 7c1a83bea4..07f33d8253 100644 --- a/src/meta/minifier.js +++ b/src/meta/minifier.js @@ -41,9 +41,21 @@ function setupDebugging() { var pool = []; var free = []; -Minifier.maxThreads = os.cpus().length - 1; +var maxThreads = 0; + +Object.defineProperty(Minifier, 'maxThreads', { + get: function () { + return maxThreads; + }, + set: function (val) { + maxThreads = val; + winston.verbose('[minifier] utilizing a maximum of ' + maxThreads + ' additional threads'); + }, + configurable: true, + enumerable: true, +}); -winston.verbose('[minifier] utilizing a maximum of ' + Minifier.maxThreads + ' additional threads'); +Minifier.maxThreads = os.cpus().length - 1; Minifier.killAll = function () { pool.forEach(function (child) {