Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gulp-dart-scss

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gulp-dart-scss - npm Package Compare versions

Comparing version 1.0.5 to 1.1.0

93

index.js

@@ -1,57 +0,66 @@

const through2 = require("through2");
const pluginError = require("plugin-error");
const PluginError = require("plugin-error");
const Transform = require("stream").Transform;
const path = require("path");
const applySourceMap = require("vinyl-sourcemaps-apply");
const dartSass = require("sass");
const applySourceMap = require("vinyl-sourcemaps-apply");
const path = require("path");
const PLUGIN_NAME = "gulp-dart-scss";
module.exports = (options = {}) => {
return through2.obj((file, encoding, callback) => {
if (file.isNull()) {
return callback(null, file);
}
return new Transform({
objectMode: true,
transform(chunk, encoding, callback) {
// Return chunk if not scss extension
if (path.extname(chunk.path) !== ".scss") {
return callback(null, chunk);
}
if (file.isStream()) {
return callback(
new pluginError("gulp-dart-scss", "Streaming not supported")
);
}
// Ignore if empty or null
if (chunk._contents.length === 0 || chunk.isNull()) {
return callback(null);
}
// Ignore _name.scss files
if (path.basename(file.path).indexOf("_") === 0) {
return callback();
}
// Ignore _name.scss files
if (path.basename(chunk.path).indexOf("_") === 0) {
return callback(null);
}
(async () => {
try {
options.sourceMap = file.sourceMap ? file.path : false;
options.file = file.path || options.file;
if (chunk.isBuffer()) {
options.sourceMap = chunk.sourceMap ? chunk.path : false;
options.file = chunk.path || options.file;
const result = await dartSass.renderSync(options);
file.contents = Buffer.from(result.css);
// Replace .scss with .css
file.path = path.join(
path.dirname(file.path),
path.basename(file.path, path.extname(file.path)) + ".css"
// Rename extension
chunk.path = path.join(
path.dirname(chunk.path),
path.basename(chunk.path, path.extname(chunk.path)) + ".css"
);
// Apply sourcemap if gulp-sourcemap is present
if (result.map && file.sourceMap) {
const map = JSON.parse(result.map);
map.file = file.relative;
map.sources = map.sources.map(source =>
path.relative(file.base, source)
try {
const renderResult = dartSass.renderSync(options);
chunk._contents = Buffer.from(renderResult.css);
if (renderResult.map && chunk.sourceMap) {
const map = JSON.parse(renderResult.map);
map.file = chunk.relative;
map.sources = map.sources.map((source) =>
path.relative(chunk.base, source)
);
applySourceMap(chunk, map);
}
return callback(null, chunk);
} catch (error) {
return callback(
new PluginError(PLUGIN_NAME, error.message, {
fileName: chunk.relative,
})
);
applySourceMap(file, map);
}
setImmediate(callback, null, file);
} catch (error) {
process.stderr.write(
`${new pluginError("gulp-dart-scss", error.message).toString()} \r\n`
} else if (chunk.isStream()) {
return callback(
new PluginError(PLUGIN_NAME, "Streaming is not supported.")
);
return callback();
}
})();
},
});
};
{
"name": "gulp-dart-scss",
"version": "1.0.5",
"version": "1.1.0",
"description": "Gulp plugin to compile Sass (.scss) to CSS using the Dart Sass compiler.",

@@ -22,4 +22,3 @@ "author": "Kasper Hesthaven",

"plugin-error": "^1.0.1",
"vinyl-sourcemaps-apply": "^0.2.1",
"through2": "4.0.2"
"vinyl-sourcemaps-apply": "^0.2.1"
},

@@ -26,0 +25,0 @@ "files": [

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc