You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.7 KiB

  1. // Generated by CoffeeScript 1.4.0
  2. var __hasProp = {}.hasOwnProperty,
  3. __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
  4. module.exports = function(BasePlugin) {
  5. var StylusPlugin;
  6. return StylusPlugin = (function(_super) {
  7. __extends(StylusPlugin, _super);
  8. function StylusPlugin() {
  9. return StylusPlugin.__super__.constructor.apply(this, arguments);
  10. }
  11. StylusPlugin.prototype.name = 'stylus';
  12. StylusPlugin.prototype.config = {
  13. useNib: true,
  14. compress: true,
  15. environments: {
  16. development: {
  17. compress: false
  18. }
  19. }
  20. };
  21. StylusPlugin.prototype.render = function(opts, next) {
  22. var content, file, inExtension, nib, outExtension, style, stylus;
  23. inExtension = opts.inExtension, outExtension = opts.outExtension, content = opts.content, file = opts.file;
  24. if ((inExtension === 'styl' || inExtension === 'stylus') && (outExtension === 'css' || outExtension === null)) {
  25. stylus = require('stylus');
  26. style = stylus(opts.content).set('filename', file.get('fullPath')).set('compress', this.config.compress);
  27. if (this.config.useNib) {
  28. nib = require('nib');
  29. style.use(nib());
  30. }
  31. return style.render(function(err, output) {
  32. if (err) {
  33. return next(err);
  34. }
  35. opts.content = output;
  36. return next();
  37. });
  38. } else {
  39. return next();
  40. }
  41. };
  42. return StylusPlugin;
  43. })(BasePlugin);
  44. };