How to use the sass.js.getPathVariations function in sass

To help you get started, we’ve selected a few 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 NickHeiner / sassjs-loader / index.js View on Github external
sassJs.importer(function(request, done) {
        // Adapted from
        // eslint-disable-next-line max-len 
        // https://github.com/amiramw/grunt-contrib-sassjs/blob/a65f869df967a4e417c4260fd93239e4f0bc55ee/tasks/sass.js#L11
		if (request.path) {
			done();
		} else if (request.resolved) {
			var realPath = request.resolved.replace(/^\/sass\//, ''),
                pathVariations = sassJs.getPathVariations(realPath);

            q.all(_.map(pathVariations, function(pathVariation) {
                return qFs.read(pathVariation)
                    .then(function(fileContents) {
                        return {
                            path: pathVariation,
                            content: fileContents
                        };
                    })
                    .catch(function(err) {
                        if (err.code === 'ENOENT') {
                            return null;
                        }
                        throw err;
                    });    
            })).then(function(files) {
github amiramw / grunt-contrib-sassjs / tasks / sass.js View on Github external
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)
					};
				}
				return null;
			}, null));
		} else {
			done();
		}
	});
	grunt.registerMultiTask('sass', 'Compile Sass to CSS', function () {
github NickHeiner / sassjs-loader / lib / get-path-variations.js View on Github external
function getPathVariations(filePath, rawPath) {
    var pathToUse = rawPath || path, 
        pathVariations = sassJs.getPathVariations(pathToUse.basename(filePath));

    return pathVariations.map(function(pathVariation) {
        return pathToUse.join(pathToUse.dirname(filePath), pathVariation);
    });
}
github imdreamrunner / browser-vue-loader / src / processors / sass / index.js View on Github external
sass.importer(async (request, done) => {
    const possiblePaths = sass.getPathVariations(request.resolved)
    for (let path of possiblePaths) {
      const fullpath = origin + path
      if (await checkResourceByUrl(fullpath)) {
        const content = await fetchContent(fullpath)
        done({content})
        break
      }
    }
  })