feat: use sass-embedded if possible (#10950)

This commit is contained in:
Opliko
2022-10-09 04:17:41 +02:00
committed by GitHub
parent 9d0b1d5092
commit 5772e0bbfb
5 changed files with 15 additions and 3 deletions

View File

@@ -165,6 +165,9 @@
"nyc": "15.1.0",
"smtp-server": "3.11.0"
},
"optionalDependencies": {
"sass-embedded": "1.55.0"
},
"bugs": {
"url": "https://github.com/NodeBB/NodeBB/issues"
},

View File

@@ -6,7 +6,7 @@ const bodyParser = require('body-parser');
const fs = require('fs');
const path = require('path');
const childProcess = require('child_process');
const sass = require('sass');
const sass = require('../src/utils').getSass();
const webpack = require('webpack');
const nconf = require('nconf');

View File

@@ -240,7 +240,7 @@ async function saveRenderedCss(data) {
if (!data.customCSS) {
return;
}
const sass = require('sass');
const sass = require('../utils').getSass();
const scssOutput = await sass.compileStringAsync(data.customCSS, {});
data.renderedCustomCSS = scssOutput.css.toString();
}

View File

@@ -4,7 +4,7 @@ const fs = require('fs');
const os = require('os');
const async = require('async');
const winston = require('winston');
const sass = require('sass');
const sass = require('../utils').getSass();
const postcss = require('postcss');
const autoprefixer = require('autoprefixer');
const clean = require('postcss-clean');

View File

@@ -29,4 +29,13 @@ utils.generateUUID = function () {
return rnd.join('-');
};
utils.getSass = function () {
try {
const sass = require('sass-embedded');
return sass;
} catch (_err) {
return require('sass');
}
};
module.exports = utils;