-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Refactoring ENB config #1349
Changes from all commits
793e65e
53678fd
ea3ae61
4dac632
a34071b
62a8554
6e63c8d
7a2f6fb
ab39e6e
f11eb0a
3d347cf
94907a0
687857a
906fb64
7e30e0c
e576215
94d8228
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
module.exports = { | ||
desktop : [ | ||
'last 2 versions', | ||
'ie 10', | ||
'ff 24', | ||
'opera 12.16' | ||
], | ||
touch : [ | ||
'android 4', | ||
'ios >= 5', | ||
'ie 10' | ||
], | ||
'touch-pad' : [ | ||
'android 4', | ||
'ios 5' | ||
], | ||
'touch-phone' : [ | ||
'android 4', | ||
'ios 6', | ||
'ie 10' | ||
] | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
var langs = process.env.BEM_I18N_LANGS, | ||
DEFAULT_LANGS = ['ru', 'en']; | ||
|
||
module.exports = langs? langs.split(' ') : [].concat(DEFAULT_LANGS); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module.exports = { | ||
desktop : ['common.blocks', 'desktop.blocks'], | ||
touch : ['common.blocks', 'touch.blocks'], | ||
'touch-pad' : ['common.blocks', 'touch.blocks', 'touch-pad.blocks'], | ||
'touch-phone' : ['common.blocks', 'touch.blocks', 'touch-phone.blocks'], | ||
test : ['test.blocks'] | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
module.exports = { | ||
'bem-core' : { | ||
path : 'libs/bem-core', | ||
levels : { | ||
desktop : ['libs/bem-core/common.blocks', 'libs/bem-core/desktop.blocks'], | ||
touch : ['libs/bem-core/common.blocks', 'libs/bem-core/touch.blocks'], | ||
'touch-pad' : ['libs/bem-core/common.blocks', 'libs/bem-core/touch.blocks'], | ||
'touch-phone' : ['libs/bem-core/common.blocks', 'libs/bem-core/touch.blocks'] | ||
} | ||
}, | ||
'bem-pr' : { | ||
path : 'libs/bem-pr', | ||
levels : { | ||
spec : ['libs/bem-pr/spec.blocks'] | ||
} | ||
}, | ||
'design' : { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. are you sure about semantical correctness of treating There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Its behavior is no different from the usual library. The only difference is that it is inside There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we have levels and libs. and we treat them as different things. so semantically there's difference. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So we need two different files: one for libs, and the other one for design? |
||
path : 'design', | ||
levels : { | ||
desktop : ['design/common.blocks', 'design/desktop.blocks'], | ||
touch : ['design/common.blocks', 'design/touch.blocks'], | ||
'touch-pad' : ['design/common.blocks', 'design/touch.blocks', 'design/touch-pad.blocks'], | ||
'touch-phone' : ['design/common.blocks', 'design/touch.blocks', 'design/touch-phone.blocks'] | ||
} | ||
} | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = ['desktop', 'touch-phone', 'touch-pad']; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = { | ||
desktop : ['common', 'desktop'], | ||
touch : ['common', 'touch'], | ||
'touch-phone' : ['common', 'touch'], | ||
'touch-pad' : ['common', 'touch'] | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
var techs = require('./techs'); | ||
|
||
module.exports = function(node, options) { | ||
var levels = options.levels || [], | ||
browsers = options.browser || [], | ||
langs = options.langs || [], | ||
templateEngine = options.templateEngine || 'BH'; | ||
|
||
// essential | ||
node.addTechs([ | ||
[techs.bem.levels, { levels : levels }], | ||
[techs.bem.bemjsonToBemdecl, { | ||
target : '.tmp.bemdecl.js' | ||
}], | ||
[techs.bem.deps, { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. tech.levels({ levels : levels }),
tech.bemjsonToBemdecl('.tmp.bemdecl.js'), // sugar for target etc. ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I reopened old issue in this topic. I propose to continue the discussion there. |
||
bemdeclFile : '.tmp.bemdecl.js', | ||
target : '.tmp.deps.js' | ||
}], | ||
[techs.bem.files, { | ||
depsFile : '.tmp.deps.js' | ||
}] | ||
]); | ||
|
||
// css | ||
node.addTech([techs.css, { | ||
target : '.tmp.css', | ||
browsers : browsers | ||
}]); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. tech.css('.tmp.css', { browsers : browsers }), There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I reopened old issue in this topic. I propose to continue the discussion there. |
||
node.mode('development', function() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd rather use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. agree |
||
node.addTech([techs.files.copy, { | ||
source : '.tmp.css', | ||
target : '?.css' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. tech.copy('.tmp.css.js', '?.css'), // sugar for source and dest (target) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I reopened old issue in this topic. I propose to continue the discussion there. |
||
}]); | ||
}); | ||
node.mode('production', function() { | ||
node.addTech([techs.process, { | ||
source : '.tmp.css', | ||
target : '?.css', | ||
minify : true, | ||
tech : 'cleancss' | ||
}]); | ||
}); | ||
node.addTarget('?.css'); | ||
|
||
// JavaScript for browsers | ||
node.addTechs([ | ||
// Template engine for JavaScript | ||
[techs.bem.depsByTechToBemdecl, { | ||
target : '.tmp.js-template.bemdecl.js', | ||
sourceTech : 'js', | ||
destTech : 'bemhtml' | ||
}], | ||
[techs.bem.deps, { | ||
target : '.tmp.js-template.deps.js', | ||
bemdeclFile : '.tmp.js-template.bemdecl.js' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In addition to I created issue about the names of options. I propose to continue the discussion there. |
||
}], | ||
[techs.bem.files, { | ||
depsFile : '.tmp.js-template.deps.js', | ||
filesTarget : '.tmp.js-template.files', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In addition to I created issue about the names of options. I propose to continue the discussion there. |
||
dirsTarget : '.tmp.js-template.dirs' | ||
}], | ||
templateEngine === 'BH'? [techs.engines.bhClient, { | ||
target : '.tmp.js-template.js', | ||
filesTarget : '.tmp.js-template.files', | ||
jsAttrName : 'data-bem', | ||
jsAttrScheme : 'json', | ||
mimic : 'BEMHTML' | ||
}] : [techs.engines.bemhtml, { | ||
target : '.tmp.js-template.js', | ||
filesTarget : '.tmp.js-template.files', | ||
devMode : false | ||
}], | ||
|
||
// JavaScript Files | ||
[techs.bem.depsByTechToBemdecl, { | ||
target : '.tmp.required-js.bemdecl.js', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why |
||
sourceTech : 'js', | ||
destTech : 'js' | ||
}], | ||
[techs.bem.mergeBemdecl, { | ||
sources : ['.tmp.bemdecl.js', '.tmp.required-js.bemdecl.js'], | ||
target : '.tmp.js.bemdecl.js' | ||
}], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. tech.mergeBemdecl(['.tmp.bemdecl.js', '.tmp.required-js.bemdecl.js'], '.tmp.js.bemdecl.js'); // sugar for sourceS and target (dest) upd swapped sources and target — sources as first arg is more intuitive, right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I reopened old issue in this topic. I propose to continue the discussion there. |
||
[techs.bem.deps, { | ||
target : '.tmp.js.deps.js', | ||
bemdeclFile : '.tmp.js.bemdecl.js' | ||
}], | ||
[techs.bem.files, { | ||
depsFile : '.tmp.js.deps.js', | ||
filesTarget : '.tmp.js.files', | ||
dirsTarget : '.tmp.js.dirs' | ||
}], | ||
|
||
// JavaScript | ||
[techs.browser.js, { | ||
filesTarget : '.tmp.js.files', | ||
target : '.tmp.source.js' | ||
}], | ||
[techs.browser.ym, { | ||
source : '.tmp.source.js', | ||
target : '.tmp.js' | ||
}] | ||
]); | ||
node.mode('development', function() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same story about having borschik in dev mode as well. and also I suggest to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. okay |
||
node.addTech([techs.files.copy, { | ||
source : '.tmp.js', | ||
target : '?.js' | ||
}]); | ||
}); | ||
node.mode('production', function() { | ||
node.addTech([techs.process, { | ||
source : '.tmp.js', | ||
target : '?.js', | ||
minify : true | ||
}]); | ||
}); | ||
node.addTarget('?.js'); | ||
|
||
// Htmls by langs | ||
node.addTechs([ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
upd like: no bemjson → no html, but have bemdecl → all is fine, just no html. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1, if it's possible with ENB There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not? |
||
templateEngine === 'BH'? [techs.engines.bhServer, { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's think about universal declaration for any template engine with the help of something like module.exports = {
engine: 'bhServer',
opts: {
jsAttrName : 'data-bem',
jsAttrScheme : 'json'
}
} and module.exports = {
engine: 'bemhtml',
opts: {
devMode : false
}
} and then var templateEngineConf = require(templateEngine === 'BH'? `./bh.conf.js` : './bemhtml.conf.js');
[techs.engines[templateEngineConf.engine], extend({
target : 'bemhtml.dev.js'
}, templateEngineConf.options)] BTW, looks like there's no way to switch to dev mode in BEMHTML? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need some proxy modules or agreement for that (oh, wait, there are enb techs already?). |
||
target : 'bemhtml.dev.js', | ||
jsAttrName : 'data-bem', | ||
jsAttrScheme : 'json' | ||
}] : [techs.engines.bemhtml, { | ||
target : 'bemhtml.dev.js', | ||
devMode : false | ||
}], | ||
[techs.process, { | ||
source : 'bemhtml.dev.js', | ||
target : 'bemhtml.js', | ||
minify : true | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what's the reason to minify bemhtml? and anyways it should depend on env There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. agree |
||
}], | ||
templateEngine === 'BH'? [techs.html.bh, { | ||
bhFile : 'bemhtml.js' | ||
}] : [techs.html.bemhtml] | ||
]); | ||
node.addTargets(['?.html']); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Or maybe |
||
|
||
langs.forEach(function(lang) { | ||
var target = '?.' + lang + '.html'; | ||
|
||
node.addTech([techs.files.copy, { | ||
source : '?.html', | ||
target : target | ||
}]); | ||
node.addTarget(target); | ||
}); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
module.exports = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe we can extend this file and publish as npm module with all the deps bundled? |
||
bem : require('enb-bem-techs'), | ||
css : require('enb-stylus/techs/css-stylus-with-autoprefixer'), | ||
files : { | ||
copy : require('enb/techs/file-copy'), | ||
merge : require('enb/techs/file-merge') | ||
}, | ||
browser : { | ||
js : require('enb-diverse-js/techs/browser-js'), | ||
ym : require('enb-modules/techs/prepend-modules') | ||
}, | ||
engines : { | ||
bemhtml : require('enb-bemxjst/techs/bemhtml-old'), | ||
bhServer : require('enb-bh/techs/bh-server-include'), | ||
bhClient : require('enb-bh/techs/bh-client-module') | ||
}, | ||
html : { | ||
bemhtml : require('enb-bemxjst/techs/html-from-bemjson'), | ||
bh : require('enb-bh/techs/html-from-bemjson') | ||
}, | ||
process : require('enb-borschik/techs/borschik') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know you want abstraction from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. okay |
||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe it's better to call this file
sets.js
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, there's
sets
as well )