Created
March 20, 2015 02:50
-
-
Save iissnan/f2c7509886dae2add82e to your computer and use it in GitHub Desktop.
Stylus plugin (draft)
This file contains hidden or 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
/** | |
* 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