Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds Eyeglass support to Terraform #124

Open
wants to merge 4 commits into
base: release-v1.0.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
node_modules
*.swp
*.log
.eyeglass_cache
16 changes: 12 additions & 4 deletions lib/stylesheet/processors/sass.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
var sass = require("node-sass")
var eyeglass = require("eyeglass")
var TerraformError = require("../../error").TerraformError

exports.compile = function(filePath, dirs, fileContents, callback){
sass.render({
var opts = {
file: filePath,
includePaths: dirs,
outputStyle: 'compressed',
sourceMap: true,
sourceMapEmbed: false,
sourceMapContents: true,
outFile: filePath,
omitSourceMapUrl: true
}, function (e, css) {
omitSourceMapUrl: true,
eyeglass: {
engines: {
sass: sass
}
}
}

sass.render(eyeglass(opts), function (e, css) {
if (e) {
var error = new TerraformError ({
source: "Sass",
Expand All @@ -24,7 +32,7 @@ exports.compile = function(filePath, dirs, fileContents, callback){
})
return callback(error)
}

callback(null, css.css, css.map.toString())
});
}
14 changes: 11 additions & 3 deletions lib/stylesheet/processors/scss.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
var scss = require("node-sass")
var eyeglass = require("eyeglass")
var TerraformError = require("../../error").TerraformError

exports.compile = function(filePath, dirs, fileContents, callback){
scss.render({
var opts = {
file: filePath,
includePaths: dirs,
outputStyle: 'compressed',
sourceMap: true,
sourceMapEmbed: false,
sourceMapContents: true,
outFile: filePath,
omitSourceMapUrl: true
}, function (e, css) {
omitSourceMapUrl: true,
eyeglass: {
engines: {
sass: scss
}
}
}

scss.render(eyeglass(opts), function (e, css) {
if (e) {
var error = new TerraformError ({
source: "Sass",
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@
"through": "2.3.8"
},
"devDependencies": {
"eyeglass": "0.8.1",
"eyeglass-sample": "0.0.3",
"mocha": "2.3.4",
"should": "1.2.2"
}
Expand Down
4 changes: 4 additions & 0 deletions test/fixtures/stylesheets/sass/eyeglass.sass
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@import "eyeglass-sample"

.sass:before
content: hello("Kenneth")
7 changes: 7 additions & 0 deletions test/fixtures/stylesheets/scss/eyeglass.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@import "eyeglass-sample";

body {
&:before {
content: hello("Kenneth")
}
}
23 changes: 23 additions & 0 deletions test/stylesheets.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,17 @@ describe("stylesheets", function(){
done()
})
})
it("should include an Eyeglass module in an SCSS file", function (done) {
poly.render("eyeglass.scss", function(error, body, sourcemap) {
should.not.exist(error)
should.exist(body)
should.exist(sourcemap)
body.should.include("Kenneth")
body.should.include("hello")
body.should.include(".sassy")
done()
})
})

})

Expand Down Expand Up @@ -194,6 +205,18 @@ describe("stylesheets", function(){
done()
})
})
it("should include an SCSS Eyeglass module in a Sass file", function (done) {
poly.render("eyeglass.sass", function(error, body, sourcemap) {
should.not.exist(error)
should.exist(body)
should.exist(sourcemap)
body.should.include("Kenneth")
body.should.include("hello")
body.should.include(".sassy")
done()
})
})


})

Expand Down