From 0e219a8c58f06fcb485a4b8d3d809abe21f5a5bd Mon Sep 17 00:00:00 2001 From: psychobunny Date: Mon, 21 Aug 2017 17:48:58 -0400 Subject: [PATCH] closes #5891 --- Gruntfile.js | 7 ++++++- src/meta/css.js | 17 ++++++++++++++++- src/plugins.js | 2 ++ src/plugins/load.js | 7 ++++++- 4 files changed, 30 insertions(+), 3 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 7fa94e3eaf..8b352d9d4b 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -83,7 +83,12 @@ module.exports = function (grunt) { }, }, lessUpdated_Admin: { - files: ['public/**/*.less'], + files: [ + 'public/*.less', + 'node_modules/nodebb-*/*.less', 'node_modules/nodebb-*/**/*.less', + '!node_modules/nodebb-*/node_modules/**', + '!node_modules/nodebb-*/.git/**', + ], options: { interval: 1000, }, diff --git a/src/meta/css.js b/src/meta/css.js index 0f20ed7aca..7621f3b6dd 100644 --- a/src/meta/css.js +++ b/src/meta/css.js @@ -118,6 +118,20 @@ function getBundleMetadata(target, callback) { }, ], cb); }, + acpLess: function (cb) { + if (target === 'client') { + return cb(null, ''); + } + + async.waterfall([ + function (next) { + filterMissingFiles(plugins.acpLessFiles, next); + }, + function (acpLessFiles, next) { + getImports(acpLessFiles, '\n@import ".', '.less', next); + }, + ], cb); + }, css: function (cb) { async.waterfall([ function (next) { @@ -133,8 +147,9 @@ function getBundleMetadata(target, callback) { function (result, next) { var cssImports = result.css; var lessImports = result.less; + var acpLessImports = result.acpLess; - var imports = cssImports + '\n' + lessImports; + var imports = cssImports + '\n' + lessImports + '\n' + acpLessImports; imports = buildImports[target](imports); next(null, { paths: paths, imports: imports }); diff --git a/src/plugins.js b/src/plugins.js index 4bec044d54..10db23eb65 100644 --- a/src/plugins.js +++ b/src/plugins.js @@ -30,6 +30,7 @@ Plugins.loadedHooks = {}; Plugins.staticDirs = {}; Plugins.cssFiles = []; Plugins.lessFiles = []; +Plugins.acpLessFiles = []; Plugins.clientScripts = []; Plugins.acpScripts = []; Plugins.libraryPaths = []; @@ -83,6 +84,7 @@ Plugins.reload = function (callback) { Plugins.versionWarning = []; Plugins.cssFiles.length = 0; Plugins.lessFiles.length = 0; + Plugins.acpLessFiles.length = 0; Plugins.clientScripts.length = 0; Plugins.acpScripts.length = 0; Plugins.libraryPaths.length = 0; diff --git a/src/plugins/load.js b/src/plugins/load.js index b077a3ed4e..8745a833a0 100644 --- a/src/plugins/load.js +++ b/src/plugins/load.js @@ -25,6 +25,9 @@ module.exports = function (Plugins) { lessFiles: function (next) { Plugins.data.getFiles(pluginData, 'less', next); }, + acpLessFiles: function (next) { + Plugins.data.getFiles(pluginData, 'acpLess', next); + }, clientScripts: function (next) { Plugins.data.getScripts(pluginData, 'client', next); }, @@ -60,6 +63,7 @@ module.exports = function (Plugins) { Object.assign(Plugins.staticDirs, results.staticDirs || {}); add(Plugins.cssFiles, results.cssFiles); add(Plugins.lessFiles, results.lessFiles); + add(Plugins.acpLessFiles, results.acpLessFiles); add(Plugins.clientScripts, results.clientScripts); add(Plugins.acpScripts, results.acpScripts); Object.assign(meta.js.scripts.modules, results.modules || {}); @@ -79,6 +83,7 @@ module.exports = function (Plugins) { Plugins.prepareForBuild = function (targets, callback) { Plugins.cssFiles.length = 0; Plugins.lessFiles.length = 0; + Plugins.acpLessFiles.length = 0; Plugins.clientScripts.length = 0; Plugins.acpScripts.length = 0; Plugins.soundpacks.length = 0; @@ -91,7 +96,7 @@ module.exports = function (Plugins) { 'client js bundle': ['clientScripts'], 'admin js bundle': ['acpScripts'], 'client side styles': ['cssFiles', 'lessFiles'], - 'admin control panel styles': ['cssFiles', 'lessFiles'], + 'admin control panel styles': ['cssFiles', 'lessFiles', 'acpLessFiles'], sounds: ['soundpack'], languages: ['languageData'], };