This repository has been archived by the owner on Dec 16, 2019. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
27 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{spawn} = require 'child_process' | ||
{BaseLanguage} = require './base' | ||
|
||
class exports.SassLanguage extends BaseLanguage | ||
compile: (file, callback) -> | ||
@readFile file, (error, data) => | ||
return callback error if error? | ||
result = '' | ||
error = null | ||
# Warning: spawning child processes is a quite slow operation. | ||
# On my machine, it's ~200ms, when compiling stylus via node.js | ||
# without spawning child process is ~20ms. | ||
options = [ | ||
'--stdin', | ||
'--load-path', (@getRootPath 'app', 'styles'), | ||
'--no-cache', | ||
] | ||
options.push '--scss' if /\.scss$/.test file | ||
sass = spawn 'sass', options | ||
sass.stdin.end data | ||
sass.stdout.on 'data', (data) -> result = data | ||
sass.stderr.on 'data', (data) -> error = data | ||
sass.on 'exit', (code) -> callback error, result.toString() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters