+29
-4
@@ -1,2 +0,3 @@ | ||
| var map = require('map-stream') | ||
| var fs = require('fs') | ||
| , map = require('map-stream') | ||
| , sass = require('node-sass') | ||
@@ -22,3 +23,7 @@ , path = require('path') | ||
| opts.data = file.contents.toString(); | ||
| if (opts.sourceComments === 'map') { | ||
| opts.file = file.path; | ||
| } else { | ||
| opts.data = file.contents.toString(); | ||
| } | ||
@@ -34,5 +39,15 @@ if (opts.includePaths && Array.isArray(opts.includePaths)) { | ||
| opts.success = function (css) { | ||
| if (typeof opts.onSuccess === 'function') opts.onSuccess(css); | ||
| opts.success = function (css, map) { | ||
| var sourceMap; | ||
| if (typeof opts.onSuccess === 'function') opts.onSuccess(css, map); | ||
| if (map) { | ||
| map = JSON.parse(map); | ||
| map.sourcesContent = getSourcesContent(map.sources); | ||
| sourceMap = new Buffer(JSON.stringify(map)).toString('base64'); | ||
| css = css.replace(/\/\*# sourceMappingURL=.*\*\//, | ||
| "/*# sourceMappingURL=data:application/json;base64," + | ||
| sourceMap + "*/"); | ||
| } | ||
| file.path = ext(file.path, '.css'); | ||
@@ -65,1 +80,11 @@ file.contents = new Buffer(css); | ||
| }; | ||
| function getSourcesContent (sources) { | ||
| sourcesContent = []; | ||
| for (var i = 0; i < sources.length; i++) { | ||
| sourcesContent[i] = fs.readFileSync(sources[i], { encoding: 'utf8' }); | ||
| } | ||
| return sourcesContent; | ||
| } |
+6
-6
| { | ||
| "name": "gulp-sass", | ||
| "version": "0.6.0", | ||
| "version": "0.7.0", | ||
| "description": "Gulp plugin for sass", | ||
@@ -24,9 +24,9 @@ "main": "index.js", | ||
| "dependencies": { | ||
| "node-sass": "~0.8.1", | ||
| "gulp-util": "~2.2.5", | ||
| "map-stream": "~0.1.0" | ||
| "node-sass": "~0.8", | ||
| "gulp-util": "~2.2", | ||
| "map-stream": "~0.1" | ||
| }, | ||
| "devDependencies": { | ||
| "tape": "~2.3.2", | ||
| "concat-stream": "~1.4.1" | ||
| "tape": "~2.3", | ||
| "concat-stream": "~1.4" | ||
| }, | ||
@@ -33,0 +33,0 @@ "jshintConfig": { |
+6
-0
@@ -45,2 +45,8 @@ [](https://travis-ci.org/dlmanning/gulp-sass) | ||
| ## Source Maps | ||
| gulp-sass now generates *inline* source maps if you pass `sourceComments: map` as an option. Note that gulp-sass will *only* generate inline source maps, so passing `sourceMap: filepath` to node-sass won't actually do anything. Enjoy your source maps! | ||
| NB: For those wondering, inline source maps are stuck onto the end of the css file instead of being in a separate map file. In this case, the original source contents are included as well, so you don't have to make sure your scss files are servable. | ||
| #Imports and Partials | ||
@@ -47,0 +53,0 @@ |
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
10902
12.92%193
11.56%80
8.11%2
100%Updated
Updated
Updated