Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function sassLoader(content) {
if (asyncSassJobQueue === null) {
const sass = require("node-sass");
const sassVersion = /^(\d+)/.exec(require("node-sass/package.json").version).pop();
if (Number(sassVersion) < 4) {
throw new Error(
"The installed version of `node-sass` is not compatible (expected: >= 4, actual: " + sassVersion + ")."
);
}
asyncSassJobQueue = async.queue(sass.render, threadPoolSize - 1);
}
const callback = this.async();
const isSync = typeof callback !== "function";
const self = this;
const resourcePath = this.resourcePath;
function addNormalizedDependency(file) {
module.exports = async ({ pattern, target, options }, { fs }) => {
let sass;
let sassVersion;
try {
sass = require('node-sass');
sassVersion = /^(\d+)/.exec(require('node-sass/package.json').version).pop();
} catch (error) {
if (error.code === 'MODULE_NOT_FOUND') {
throw new Error(
'Running this requires `node-sass` >=4. Please install it and re-run.',
);
}
throw error;
}
if (Number(sassVersion) < 4) {
throw new Error(
`The installed version of \`node-sass\` is not compatible (expected: >= 4, actual: ${sassVersion}).`,
);
}
const render = opts => new Promise((resolve, reject) => {
initializeCompiler() {
scss = require('node-sass');
return require('node-sass/package.json').version;
}
}