Node.js based forum software built for the modern web
perf: speed up build
Barış Soner Uşaklıdd4e9cce0940
diff --git a/Gruntfile.js b/Gruntfile.jsindex ea8c518ec7..3f635ac9a0 100644--- a/Gruntfile.js+++ b/Gruntfile.js@@ -138,10 +138,9 @@ module.exports = function (grunt) {});const build = require('./src/meta/build');if (!grunt.option('skip')) {- await build.build(true, { webpack: false });+ await build.build(true, { watch: true });}run();- await build.webpack({ watch: true });done();});diff --git a/src/meta/build.js b/src/meta/build.jsindex 5f272387b3..1941291020 100644--- a/src/meta/build.js+++ b/src/meta/build.js@@ -77,20 +77,36 @@ async function beforeBuild(targets) {const allTargets = Object.keys(targetHandlers).filter(name => typeof targetHandlers[name] === 'function');-async function buildTargets(targets, parallel) {+async function buildTargets(targets, parallel, options) {const length = Math.max(...targets.map(name => name.length));-- if (parallel) {+ const jsTargets = targets.filter(target => targetHandlers.javascript.includes(target));+ const otherTargets = targets.filter(target => !targetHandlers.javascript.includes(target));+ async function buildJSTargets() {await Promise.all(- targets.map(+ jsTargets.map(target => step(target, parallel, `${_.padStart(target, length)} `)));+ // run webpack after jstargets are done, no need to wait for css/templates etc.+ if (options.webpack || options.watch) {+ await exports.webpack(options);+ }+ }+ if (parallel) {+ await Promise.all([+ buildJSTargets(),+ ...otherTargets.map(+ target => step(target, parallel, `${_.padStart(target, length)} `)+ ),+ ]);} else {for (const target of targets) {// eslint-disable-next-line no-await-in-loopawait step(target, parallel, `${_.padStart(target, length)} `);}+ if (options.webpack || options.watch) {+ await exports.webpack(options);+ }}}@@ -175,11 +191,7 @@ exports.build = async function (targets, options) {}const startTime = Date.now();- await buildTargets(targets, !series);-- if (options.webpack) {- await exports.webpack(options);- }+ await buildTargets(targets, !series, options);const totalTime = (Date.now() - startTime) / 1000;await cacheBuster.write();