diff --git a/index.js b/index.js new file mode 100644 index 0000000..91aed87 --- /dev/null +++ b/index.js @@ -0,0 +1,26 @@ +var es = require('event-stream') + , clone = require('clone') + , sass = require('node-sass') + , ext = require('gulp-util').replaceExtension + ; + +module.exports = function (options) { + var opts = options ? clone(options) : {}; + + function nodeSass (file, cb) { + var newFile = clone(file); + + sass.render({ + data: newFile.contents.toString(), + success: function (css) { + newFile.path = ext(newFile.path, '.css') + newFile.shortened = newFile.shortened && ext(newFile.shortened, '.css'); + newFile.contents = new Buffer(css); + + cb(null, newFile); + } + }); + } + + return es.map(nodeSass); +} \ No newline at end of file diff --git a/package.json b/package.json index 2ce630b..0fe629c 100644 --- a/package.json +++ b/package.json @@ -17,5 +17,14 @@ "license": "MIT", "bugs": { "url": "https://github.com/dlmanning/gulp-sass/issues" + }, + "dependencies": { + "node-sass": "~0.6.4", + "event-stream": "~3.0.16", + "clone": "~0.1.10", + "gulp-util": "0.0.1" + }, + "devDependencies": { + "gulp": "~0.2.0" } } diff --git a/test/css/inheritance.css b/test/css/inheritance.css new file mode 100644 index 0000000..ba5c099 --- /dev/null +++ b/test/css/inheritance.css @@ -0,0 +1,10 @@ +.error, .badError { + border: 1px red; + background: #ffdddd; } + +.error.intrusion { + font-size: 1.3em; + font-weight: bold; } + +.badError { + border-width: 3px; } diff --git a/test/css/mixins.css b/test/css/mixins.css new file mode 100644 index 0000000..f1a00f5 --- /dev/null +++ b/test/css/mixins.css @@ -0,0 +1,8 @@ +#data { + float: left; + margin-left: 10px; } + #data th { + text-align: center; + font-weight: bold; } + #data td, #data th { + padding: 2px; } diff --git a/test/css/nesting.css b/test/css/nesting.css new file mode 100644 index 0000000..5a7d6bb --- /dev/null +++ b/test/css/nesting.css @@ -0,0 +1,9 @@ +table.hl { + margin: 2em 0; } + table.hl td.ln { + text-align: right; } + +li { + font-family: serif; + font-weight: bold; + font-size: 1.2em; } diff --git a/test/css/variables.css b/test/css/variables.css new file mode 100644 index 0000000..217dd34 --- /dev/null +++ b/test/css/variables.css @@ -0,0 +1,8 @@ +.content-navigation { + border-color: #3bbfce; + color: #2ca2af; } + +.border { + padding: 8px; + margin: 8px; + border-color: #3bbfce; } diff --git a/test/scss/inheritance.scss b/test/scss/inheritance.scss new file mode 100644 index 0000000..c9e0f85 --- /dev/null +++ b/test/scss/inheritance.scss @@ -0,0 +1,13 @@ +.error { + border: 1px #f00; + background: #fdd; +} +.error.intrusion { + font-size: 1.3em; + font-weight: bold; +} + +.badError { + @extend .error; + border-width: 3px; +} \ No newline at end of file diff --git a/test/scss/mixins.scss b/test/scss/mixins.scss new file mode 100644 index 0000000..3b81f73 --- /dev/null +++ b/test/scss/mixins.scss @@ -0,0 +1,17 @@ +@mixin table-base { + th { + text-align: center; + font-weight: bold; + } + td, th {padding: 2px} +} + +@mixin left($dist) { + float: left; + margin-left: $dist; +} + +#data { + @include left(10px); + @include table-base; +} \ No newline at end of file diff --git a/test/scss/nesting.scss b/test/scss/nesting.scss new file mode 100644 index 0000000..d3300ea --- /dev/null +++ b/test/scss/nesting.scss @@ -0,0 +1,14 @@ +table.hl { + margin: 2em 0; + td.ln { + text-align: right; + } +} + +li { + font: { + family: serif; + weight: bold; + size: 1.2em; + } +} diff --git a/test/scss/variables.scss b/test/scss/variables.scss new file mode 100644 index 0000000..7c5de0f --- /dev/null +++ b/test/scss/variables.scss @@ -0,0 +1,14 @@ +$blue: #3bbfce; +$margin: 16px; + +.content-navigation { + border-color: $blue; + color: + darken($blue, 9%); +} + +.border { + padding: $margin / 2; + margin: $margin / 2; + border-color: $blue; +} \ No newline at end of file diff --git a/test/test.js b/test/test.js new file mode 100644 index 0000000..ac0fb15 --- /dev/null +++ b/test/test.js @@ -0,0 +1,7 @@ +var gulp = require('gulp') + , sass = require('../') + ; + +gulp.src('./scss/*.scss') + .pipe(sass()) + .pipe(gulp.dest('./css/')); \ No newline at end of file