Created
October 24, 2014 12:58
-
-
Save awinogradov/6721df7ed4b4c13d771a to your computer and use it in GitHub Desktop.
Ё маё
This file contains 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
exports.deps = [ | |
{ | |
"block": "page" | |
}, | |
{ | |
"block": "page", | |
"elem": "css" | |
}, | |
{ | |
"block": "page", | |
"elem": "js" | |
}, | |
{ | |
"block": "page", | |
"elem": "header" | |
}, | |
{ | |
"block": "page", | |
"elem": "content" | |
}, | |
{ | |
"block": "page", | |
"elem": "footer" | |
} | |
]; |
This file contains 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
var path = require('path'); | |
YENV = 'development'; | |
// Technologies | |
var techs = { | |
levels : require('enb/techs/levels'), | |
files : require('enb/techs/files'), | |
provider : require('enb/techs/file-provider'), | |
copy : require('enb/techs/file-copy'), | |
merge : require('enb/techs/file-merge'), | |
bemdecl : require('enb/techs/bemdecl-from-bemjson'), | |
deps : require('enb/techs/deps'), | |
modules : require('enb-modules/techs/prepend-modules'), | |
js : require('enb-diverse-js/techs/browser-js'), | |
stylus : require('enb-stylus/techs/css-stylus'), | |
autoprefixer : require('enb-autoprefixer/techs/css-autoprefixer'), | |
bemhtml : require('enb-bemxjst/techs/bemhtml'), | |
bemtree : require('enb-bemxjst/techs/bemtree'), | |
html : require('enb-bemxjst/techs/html-from-bemjson'), | |
borschik : require('enb-borschik/techs/borschik'), | |
nodejs : require('enb-diverse-js/techs/node-js'), | |
'enb-modules' : require('enb-modules/techs/prepend-modules') | |
}; | |
/** | |
* Levels for project | |
* | |
* @param {Object} config | |
* @returns {*|Array} | |
*/ | |
function projectLevels(config) { | |
return [ | |
{ path : 'libs/bem-core/common.blocks', check : false }, | |
{ path : 'libs/bem-components/common.blocks', check : false }, | |
{ path : 'libs/bem-components/desktop.blocks', check : false }, | |
{ path : 'libs/forms/default.blocks', check : false }, | |
{ path : 'libs/forms/design/default.blocks', check : false }, | |
{ path : 'libs/forms/design/themed.blocks', check : false }, | |
'common.blocks', | |
'project.blocks' | |
] | |
.map(function(level) { | |
return config.resolvePath(level); | |
}); | |
} | |
/** | |
* Builder | |
* | |
* @param {Object} config | |
*/ | |
module.exports = function(config) { | |
// Technologies for all bundles | |
config.nodes('project.bundles/*', function(nodeConfig) { | |
nodeConfig.addTechs([ | |
use('files'), | |
use('deps', { target : '?.bemdecl.js' }), | |
use('levels', { levels : projectLevels(config) }), | |
use('provider', { target : '?.bemjson.js' }), | |
use('bemdecl'), | |
use('js', { target : '?.pre.js' }), | |
use('modules', { target : '?.js', source : '?.pre.js' }), | |
use('stylus', { target : '?.noprefix.css' }), | |
use('autoprefixer', { | |
browserSupport : [ | |
"last 2 versions", | |
"ios 6" | |
], | |
sourceTarget : '?.noprefix.css' | |
}), | |
use('bemtree', { devMode: false }), | |
use('bemhtml', { devMode : false }), | |
use('html') | |
]); | |
nodeConfig.addTargets([ | |
'?.min.js', '?.min.css', '?.html', '?.bemtree.js' | |
]); | |
}); | |
// Development | |
config.mode('development', function() { | |
config.nodes('project.bundles/*', function(nodeConfig) { | |
nodeConfig.addTechs([ | |
use('copy', { sourceTarget : '?.css', destTarget : '?.min.css' }), | |
use('borschik', { sourceTarget : '?.js', destTarget : '?.borschik.js', minify : false, freeze : true }), | |
use('copy', { sourceTarget : '?.borschik.js', destTarget : '?.min.js' }) | |
]); | |
}); | |
}); | |
// Test | |
config.mode('testing', function() { | |
config.nodes('project.bundles/*', function(nodeConfig) { | |
nodeConfig.addTechs([ | |
use('borschik', { sourceTarget : '?.css', destTarget : '?.min.css', minify : true, freeze : true }), | |
use('borschik', { sourceTarget : '?.js', destTarget : '?.min.js', minify : true, freeze : true }) | |
]); | |
}); | |
}); | |
// Production | |
config.mode('production', function() { | |
config.nodes('project.bundles/*', function(nodeConfig) { | |
nodeConfig.addTechs([ | |
use('borschik', { sourceTarget : '?.css', destTarget : '?.min.css', minify : true, freeze : true }), | |
use('borschik', { sourceTarget : '?.js', destTarget : '?.min.js', minify : true, freeze : true }) | |
]); | |
}); | |
}); | |
}; | |
/** | |
* Resolve tech for `nodeConfig` | |
* | |
* @param {String} tech - tech name | |
* @param {Object} params - tech params | |
* @returns {*[]} | |
*/ | |
function use(tech, params) { | |
return [ | |
techs[tech], | |
params || {} | |
]; | |
} |
This file contains 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
[{ | |
mustDeps : [ | |
{ block : 'button' }, | |
{ block : 'link' } | |
] | |
}] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment