How to use the node-sass.renderAsync function in node-sass

To help you get started, we’ve selected a few node-sass examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github maxlapides / dovetailer / lib / styles.js View on Github external
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
      })
  }
github jgranstrom / sass-extract / src / extract.js View on Github external
.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));
    });
  });
}
github jgranstrom / sass-extract / src / render.js View on Github external
export function render(compileOptions = {}, extractOptions) {
  return sass.renderAsync(compileOptions)
  .then(rendered => {
    return extract(rendered, { compileOptions, extractOptions })
    .then(vars => {
      rendered.vars = vars;
      return rendered;
    });
  });
}