Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const saveFilePath = path.join(savePath, saveFileName)
const sassOpts = {
file: sassPath,
outputStyle: 'expanded',
sourceMapEmbed: true,
outFile: saveFilePath,
sourceMapContents: true
}
const autoprefixerOpts = {
// need -moz and -webkit prefixes on css gradients
browsers: ['>0.25%', 'not op_mini all', 'Firefox > 14', 'Chrome > 24']
}
return sass
.renderAsync(sassOpts)
.then(({ css }) => {
return postcss([autoprefixer(autoprefixerOpts)]).process(css, {
from: sassPath,
to: savePath
})
})
.then(({ css }) => {
FileSaver.saveCss(
savePath.endsWith('common') ? null : this.tplName,
saveFileName,
css
)
return css
})
}
.then(({ compiledFiles, orderedFiles }) => {
const parsedDeclarations = parseFiles(compiledFiles);
const extractions = processFiles(orderedFiles, compiledFiles, parsedDeclarations, pluggable);
const importer = makeImporter(extractions, includedFiles, includedPaths, compileOptions.importer);
const extractionCompileOptions = makeExtractionCompileOptions(compileOptions, entryFilename, extractions, importer);
return sass.renderAsync(extractionCompileOptions)
.then(() => {
return pluggable.run(Pluggable.POST_EXTRACT, compileExtractionResult(orderedFiles, extractions));
});
});
}
export function render(compileOptions = {}, extractOptions) {
return sass.renderAsync(compileOptions)
.then(rendered => {
return extract(rendered, { compileOptions, extractOptions })
.then(vars => {
rendered.vars = vars;
return rendered;
});
});
}