Skip to content

Instantly share code, notes, and snippets.

@iissnan
Created March 20, 2015 02:50
Show Gist options
  • Save iissnan/f2c7509886dae2add82e to your computer and use it in GitHub Desktop.
Save iissnan/f2c7509886dae2add82e to your computer and use it in GitHub Desktop.
Stylus plugin (draft)
/**
* Stylus Plugin
*
* `import-if` - Import files if they exist.
*/
var path = require('path');
var fs = require('fs');
module.exports = function () {
return function (style) {
style.include(__dirname);
console.log(1);
style.import("_compact");
style.define('import-if', function (param) {
var file = param.val;
var filePath = path.join(__dirname, file + '.styl');
if ( fs.existsSync(filePath) ) {
console.log("Importing file: " + file);
style.import("404");
}
});
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment