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

Add support for sass as well as node-sass #249

Open
wants to merge 1 commit into
base: master
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 @@ -7,3 +7,4 @@ npm-debug.log
tmp/
doc/
.idea
mincer.iml
15 changes: 12 additions & 3 deletions lib/mincer/engines/sass_engine.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* class SassEngine
*
* Engine for the SASS/SCSS compiler. You will need `node-sass` Node module installed
* Engine for the SASS/SCSS compiler. You will need `node-sass` or `sass` Node module installed
* in order to use [[Mincer]] with `*.sass` or `*.scss` files:
*
* npm install node-sass
Expand Down Expand Up @@ -36,8 +36,17 @@ var logger = require('../logger');
// Class constructor
var SassEngine = module.exports = function SassEngine() {
Template.apply(this, arguments);
sass = sass || Template.libs['node-sass'] || require('node-sass');

sass = sass || Template.libs['sass'] || Template.libs['node-sass'] || ['sass', 'node-sass'].reduce(function(acc, module) {
if (acc) return acc;
try {
return require(module);
} catch(e) {
return null;
}
}, sass);
if (!sass) {
throw new Error('sass not loaded');
}
// Ensure node sass module has renderSync method
if (!sass.renderSync) {
throw new Error('node-sass < v0.5 is not supported.');
Expand Down