mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-07-07 19:22:09 +02:00
feat: improve grunt restart/rebuild speed
This commit is contained in:
@@ -201,7 +201,7 @@ CSS.buildBundle = function (target, fork, callback) {
|
||||
getBundleMetadata(target, next);
|
||||
},
|
||||
function (data, next) {
|
||||
var minify = global.env !== 'development';
|
||||
var minify = process.env.NODE_ENV !== 'development';
|
||||
minifier.css.bundle(data.imports, data.paths, minify, fork, next);
|
||||
},
|
||||
function (bundle, next) {
|
||||
|
||||
@@ -260,7 +260,7 @@ JS.buildModules = function (fork, callback) {
|
||||
async.waterfall([
|
||||
clearModules,
|
||||
function (next) {
|
||||
if (global.env === 'development') {
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
return linkModules(callback);
|
||||
}
|
||||
|
||||
@@ -323,7 +323,7 @@ function getBundleScriptList(target, callback) {
|
||||
|
||||
var scripts = JS.scripts.base;
|
||||
|
||||
if (target === 'client' && global.env !== 'development') {
|
||||
if (target === 'client' && process.env.NODE_ENV !== 'development') {
|
||||
scripts = scripts.concat(JS.scripts.rjs);
|
||||
} else if (target === 'acp') {
|
||||
scripts = scripts.concat(JS.scripts.admin);
|
||||
@@ -357,7 +357,7 @@ JS.buildBundle = function (target, fork, callback) {
|
||||
});
|
||||
},
|
||||
function (files, next) {
|
||||
var minify = global.env !== 'development';
|
||||
var minify = process.env.NODE_ENV !== 'development';
|
||||
var filePath = path.join(__dirname, '../../build/public', fileNames[target]);
|
||||
|
||||
minifier.js.bundle({
|
||||
|
||||
@@ -56,7 +56,7 @@ async function getTranslationMetadata() {
|
||||
}
|
||||
|
||||
async function writeLanguageFile(language, namespace, translations) {
|
||||
const dev = global.env === 'development';
|
||||
const dev = process.env.NODE_ENV === 'development';
|
||||
const filePath = path.join(buildLanguagesPath, language, namespace + '.json');
|
||||
|
||||
await mkdirp(path.dirname(filePath));
|
||||
|
||||
@@ -115,7 +115,7 @@ async function compileTemplate(filename, source) {
|
||||
|
||||
source = await processImports(paths, filename, source);
|
||||
const compiled = await Benchpress.precompile(source, {
|
||||
minify: global.env !== 'development',
|
||||
minify: process.env.NODE_ENV !== 'development',
|
||||
});
|
||||
return await fsWriteFile(path.join(viewsPath, filename.replace(/\.tpl$/, '.js')), compiled);
|
||||
}
|
||||
@@ -139,7 +139,7 @@ async function compile() {
|
||||
await mkdirp(path.join(viewsPath, path.dirname(name)));
|
||||
|
||||
await fsWriteFile(path.join(viewsPath, name), imported);
|
||||
const compiled = await Benchpress.precompile(imported, { minify: global.env !== 'development' });
|
||||
const compiled = await Benchpress.precompile(imported, { minify: process.env.NODE_ENV !== 'development' });
|
||||
await fsWriteFile(path.join(viewsPath, name.replace(/\.tpl$/, '.js')), compiled);
|
||||
}));
|
||||
|
||||
|
||||
@@ -118,6 +118,15 @@ function addProcessHandlers() {
|
||||
require('./meta').js.killMinifier();
|
||||
shutdown(1);
|
||||
});
|
||||
process.on('message', function (msg) {
|
||||
if (msg && msg.compiling === 'tpl') {
|
||||
const benchpressjs = require('benchpressjs');
|
||||
benchpressjs.flush();
|
||||
} else if (msg && msg.compiling === 'lang') {
|
||||
const translator = require('./translator');
|
||||
translator.flush();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function restart() {
|
||||
|
||||
Reference in New Issue
Block a user