diff --git a/package.json b/package.json index d8dc5b3..095a818 100644 --- a/package.json +++ b/package.json @@ -44,6 +44,7 @@ }, "dependencies": { "autoprefixer-core": "5.2.0", + "nib": "1.1.0", "postcss": "4.1.11", "postcss-import": "5.2.2", "postcss-url": "3.2.0", diff --git a/techs/stylus.js b/techs/stylus.js index 15d0849..d0250dd 100644 --- a/techs/stylus.js +++ b/techs/stylus.js @@ -55,6 +55,7 @@ var path = require('path'), url = require('postcss-url'), stylus = require('stylus'), autoprefixer = require('autoprefixer-core'), + nib = require('nib'), EOL = require('os').EOL; module.exports = require('enb/lib/build-flow').create() @@ -69,6 +70,7 @@ module.exports = require('enb/lib/build-flow').create() .defineOption('prefix', '') .defineOption('includes', []) .defineOption('hoist', false) + .defineOption('useNib', false) .useFileList(['styl', 'css']) .builder(function (sourceFiles) { var node = this.node, @@ -157,6 +159,12 @@ module.exports = require('enb/lib/build-flow').create() }); } + if (this._useNib) { + renderer + .use(nib()) + .import(nib.path + '/nib'); + } + var defer = vow.defer(); this._configureRenderer(renderer).render(function (err, css) { diff --git a/test/stylus-tech.test.js b/test/stylus-tech.test.js index a2828ab..2e58452 100644 --- a/test/stylus-tech.test.js +++ b/test/stylus-tech.test.js @@ -6,7 +6,8 @@ var fs = require('fs'), MockNode = require('mock-enb/lib/mock-node'), FileList = require('enb/lib/file-list'), StylusTech = require('../techs/stylus'), - stylus = mockFsHelper.duplicateFSInMemory(path.join(__dirname, 'fixtures', 'stylus')); + stylus = mockFsHelper.duplicateFSInMemory(path.join(__dirname, 'fixtures', 'stylus')), + nib = mockFsHelper.duplicateFSInMemory(path.resolve('node_modules', 'nib')); describe('stylus-tech', function () { afterEach(function () { @@ -223,6 +224,21 @@ describe('stylus-tech', function () { }); }); }); + + describe('nib', function () { + it('must use mixins', function () { + var scheme = { + blocks: { + 'block.styl': 'body { size: 5em 10em; }' + } + }, + expected = 'body{width:5em;height:10em;}'; + + return build(scheme, { useNib: true }).then(function (actual) { + actual.must.equal(expected); + }); + }); + }); }); function build (scheme, options) { @@ -231,7 +247,8 @@ function build (scheme, options) { bundle: {}, // jscs:disable node_modules: { - stylus: stylus + stylus: stylus, + nib: nib } // jscs:enable },