How to use the node-sass/package.json.version 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 aermin / ghChat / node_modules / sass-loader / lib / loader.js View on Github external
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) {
github wix / haste / packages / haste-task-sass / src / index.js View on Github external
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) => {
github electron-userland / electron-compilers / src / css / scss.js View on Github external
initializeCompiler() {
    scss = require('node-sass');
    return require('node-sass/package.json').version;
  }
}