Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function compile(load) {
// skip empty files
if (!load.source || load.source === '') {
return '';
}
// compile module
const urlBase = `${path.dirname(load.address)}/`;
let options = {};
if (pluginOptions.sassOptions) {
options = Object.assign({}, pluginOptions.sassOptions);
}
options.style = compileOpts.minify ? sass.style.compressed : sass.style.expanded;
options.indentedSyntax = load.address.endsWith('.sass');
options.importer = { urlBase };
let { status, text, formatted } = await new Promise(resolve => { // eslint-disable-line
sass.compile(load.source, options, resolve);
});
if (status !== 0) {
throw formatted;
}
// rewrite urls and copy assets if enabled
if (pluginOptions.rewriteUrl) {
const CssUrlRewriterModule = await System.import('css-url-rewriter-ex', __moduleName);
const CssUrlRewriter = CssUrlRewriterModule.default;
const urlRewriter = new CssUrlRewriter({ root: System.baseURL });
text = urlRewriter.rewrite(load.address, text);
if (pluginOptions.copyAssets) {
'use strict';
var Sass = require('sass.js');
var Q = require('q');
var PATH = require('path');
Sass.options({
style: Sass.style.expanded
});
module.exports = function (grunt) {
Sass.importer(function (request, done) {
if (request.path) {
done();
} else if (request.resolved) {
var realPath = request.resolved.replace(/^\/sass\//, "");
done(Sass.getPathVariations(realPath).reduce(function (found, path) {
if (found) {
return found;
}
if (grunt.file.exists(path) && !grunt.file.isDir(path)) {
return {
path: request.resolved.substr(0, request.resolved.lastIndexOf('/') + 1) + PATH.basename(path),
content: grunt.file.read(path)
};