Skip to content

Commit

Permalink
Support for custom CSS techs
Browse files Browse the repository at this point in the history
  • Loading branch information
tadatuta committed Sep 23, 2016
1 parent c7c2552 commit 05493d1
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 4 deletions.
21 changes: 21 additions & 0 deletions examples/silly/.enb/make.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,25 @@ module.exports = function (config) {
{ path: 'blocks', check: true }
]
});

var specsPostCSS = config.module('enb-bem-specs').createConfigurator('specs-postcss');

specsPostCSS.configure({
langs: true,
destPath: 'postcss-set.specs',
levels: ['blocks'],
cssEngine: {
tech: require('enb-postcss/techs/enb-postcss'),
options: {
plugins: [
require('postcss-import')()
]
}
},
sourceLevels: [
{ path: '../libs/bem-core/common.blocks', check: false },
{ path: '../libs/bem-pr/spec.blocks', check: false },
{ path: 'blocks', check: true }
]
});
};
3 changes: 3 additions & 0 deletions examples/silly/blocks/block/block.post.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.block {
color: red;
}
8 changes: 6 additions & 2 deletions lib/node-configurator.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ var path = require('path'),
htmlTechOptionNames: { bemjsonFile: 'bemjsonFile', templateFile: 'bemhtmlFile' }
},

css = require('enb-stylus/techs/stylus'),
cssEngineDefault = {
tech: require('enb-stylus/techs/stylus'),
options: {}
},

js = require('enb-js/techs/browser-js'),
borschikJs = require('enb-borschik/techs/js-borschik-include'),
Expand All @@ -39,6 +42,7 @@ exports.configure = function (config, options) {
var root = config.getRootPath(),
pattern = path.join(options.destPath, '*'),
templateEngine = options.templateEngine || templateEngineDefault,
cssEngine = options.cssEngine || cssEngineDefault,
sourceLevels = [].concat(options.sourceLevels),
depsTech,
htmlTechOpts = {};
Expand Down Expand Up @@ -207,7 +211,7 @@ exports.configure = function (config, options) {
}

// CSS
nodeConfig.addTech(css);
nodeConfig.addTech([cssEngine.tech, _.assign({}, cssEngine.options, { target: '?.css' })]);

nodeConfig.addTargets([
'?.spec.js', '?.css', '?.html'
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,19 @@
"enb": ">= 0.13.0 < 2.0.0",
"enb-bh": "1.2.0",
"enb-magic-factory": ">= 0.3.0 < 1.0.0",
"enb-postcss": "^1.1.0",
"eslint": "2.5.3",
"eslint-config-pedant": "0.1.1",
"jscs": "1.11.0"
"jscs": "1.11.0",
"postcss-import": "^8.1.2"
},
"main": "lib/index.js",
"scripts": {
"test": "npm run lint && npm run test-silly",
"lint": "eslint . && jscs .",
"test-silly": "npm run clean && npm run fixtures && npm run build-examples && npm run clean && npm run build-examples-coverage",
"fixtures": "cd examples && bower i",
"build-examples": "enb -d examples/silly make __magic__ set.specs && enb -d examples/silly make specs-bh",
"build-examples": "enb -d examples/silly make __magic__ set.specs && enb -d examples/silly make specs-bh && enb -d examples/silly make specs-postcss",
"build-examples-coverage": "ISTANBUL_COVERAGE=yes npm run build-examples && istanbul report text --include examples/silly/coverage.json",
"clean": "rm -rf examples/*/set.* && rm -rf examples/*/.enb/tmp && rm -rf examples/*/coverage.json"
}
Expand Down

0 comments on commit 05493d1

Please sign in to comment.