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

Added support for sourcesContent and update to node-sass v2.0.1 #43

Closed
Closed
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
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ var outputTree = compileSass(inputTrees, inputFile, outputFile, options);

* **`outputFile`**: Relative path of the output CSS file.

* **`options`**: A hash of options for libsass. Supported options are
`imagePath`, `outputStyle`, `precision`, `sourceComments`, and `sourceMap`.
* **`options`**: A hash of options for libsass. Supported options are:
`imagePath`, `indentedSyntax`, `omitSourceMapUrl`, `outputStyle`, `precision`,
`sourceComments`, `sourceMap`, `sourceMapEmbed`, and `sourceMapContents`.

### Example

Expand Down
37 changes: 25 additions & 12 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ var includePathSearcher = require('include-path-searcher')
var CachingWriter = require('broccoli-caching-writer')
var sass = require('node-sass')
var _ = require('lodash')
var Promise = require('rsvp').Promise
var rsvp = require('rsvp')
var Promise = rsvp.Promise
var fs = require('fs')
var writeFile = rsvp.denodeify(fs.writeFile)

module.exports = SassCompiler
SassCompiler.prototype = Object.create(CachingWriter.prototype)
Expand All @@ -20,33 +23,43 @@ function SassCompiler (inputTrees, inputFile, outputFile, options) {
options = options || {}
this.sassOptions = {
imagePath: options.imagePath,
indentedSyntax: options.indentedSyntax,
omitSourceMapUrl: options.omitSourceMapUrl,
outputStyle: options.outputStyle,
precision: options.precision,
sourceComments: options.sourceComments,
sourceMap: options.sourceMap,
precision: options.precision
sourceMapEmbed: options.sourceMapEmbed,
sourceMapContents: options.sourceMapContents
}
}


SassCompiler.prototype.updateCache = function(includePaths, destDir) {
var self = this

return new Promise(function(resolve, reject) {
var destFile = path.join(destDir, self.outputFile)
var destFile = path.join(destDir, this.outputFile)
var sourceMapFile = this.sassOptions.sourceMap
if (typeof sourceMapFile !== 'string') {
sourceMapFile = destFile + '.map'
}
mkdirp.sync(path.dirname(destFile))

var sassOptions = {
file: includePathSearcher.findFileSync(self.inputFile, includePaths),
file: includePathSearcher.findFileSync(this.inputFile, includePaths),
includePaths: includePaths,
outFile: destFile,
success: function() {
resolve(this)
},
success: function(result) {
var promises = [writeFile(destFile, result.css)]
if (this.sassOptions.sourceMap) {
promises.push(writeFile(sourceMapFile, result.map))
}
resolve(Promise.all(promises))
}.bind(this),
error: function(err) {
reject(err)
}
}
_.merge(sassOptions, self.sassOptions)
sass.renderFile(sassOptions)
})
_.merge(sassOptions, this.sassOptions)
sass.render(sassOptions)
}.bind(this))
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "broccoli-sass",
"description": "Libsass-based Sass compiler for Broccoli",
"version": "0.3.3",
"version": "0.4.0",
"author": "Jo Liss <joliss42@gmail.com>",
"main": "index.js",
"license": "MIT",
Expand All @@ -21,7 +21,7 @@
"include-path-searcher": "^0.1.0",
"lodash": "~2.4.1",
"mkdirp": "^0.3.5",
"node-sass": "^1.1.4",
"node-sass": "^2.0.1",
"rsvp": "^3.0.6"
}
}