How to use the sass.js.compileFile 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 amiramw / grunt-contrib-sassjs / tasks / sass.js View on Github external
Q.all(files.map(function (file) {
			var deferred = Q.defer();
			var src = file.src[0];
			Sass.writeFile(src, grunt.file.read(src));
			if (PATH.basename(src)[0] !== '_') {
				Sass.compileFile(src, function (result) {
					if  (result.status !== 0) {
						grunt.log.error(result.formatted + '\n');
						grunt.warn('');
						deferred.reject();
					} else {
						try {
							var cssFullPath = file.dest;
							var content = result.text;
							if (data.sourceMap && result.map) {
								var cssFile = PATH.basename(cssFullPath);
								content = "/*# sourceMappingURL=" + cssFile + ".map */\n" + content;
								var rootDirectory = "sass/" + PATH.dirname(src);
								result.map.file = cssFile;
								result.map.sources = result.map.sources.map(function (source) {
									return PATH.relative(rootDirectory, source).replace(/\\/g, "/");
								});
github WriterLighter / WriterLighter-old / src / js / modules / theme.js View on Github external
wl.config.set("theme", theme);
    if (wl.extension.get(theme, "path") != null) {
      const themeFile = path.join(wl.extension.get(theme, "path"), wl.extension.get(theme, "main"));
      const { ext } = path.parse(themeFile);
      switch (ext) {
        case "css":
          return fs.readFile(themeFile, function(e, r){
            if (e != null) { throw e; }
            return $theme.html(r);
          });

        case "sass":
          return sass.compileFile(themeFile, r=> $theme.html(r));

        case "scss":
          return sass.compileFile(themeFile, r=> $theme.html(r));

        case "less":
          return less.renderFile(themeFile, r=> $theme.html(r));
      }
    }
  }