-1 Removal
+5 Additions
var fs = require('fs'),var fs = require('fs'),
path = require('path'), path = require('path'),
techs = { techs = {
// essential // essential
fileProvider: require('enb/techs/file-provider'), fileProvider: require('enb/techs/file-provider'),
fileMerge: require('enb/techs/file-merge'), fileMerge: require('enb/techs/file-merge'),
// optimization // optimization
borschik: require('enb-borschik/techs/borschik'), borschik: require('enb-borschik/techs/borschik'),
// css // css
postcss: require('enb-postcss/techs/enb-postcss'), postcss: require('enb-postcss/techs/enb-postcss'),
postcssPlugins: [ postcssPlugins: [
require('postcss-import')(), require('postcss-import')(),
require('postcss-each'), require('postcss-each'),
require('postcss-for'), require('postcss-for'),
require('postcss-simple-vars')(), require('postcss-simple-vars')(),
require('postcss-calc')(), require('postcss-calc')(),
require('postcss-nested'), require('postcss-nested'),
require('rebem-css'), require('rebem-css'),
require('postcss-url')({ url: 'inline' }), require('postcss-url')({ url: 'inline' }),
require('autoprefixer')(), require('autoprefixer')(),
require('postcss-reporter')() require('postcss-reporter')()
], ],
// js // js
browserJs: require('enb-js/techs/browser-js'), browserJs: require('enb-js/techs/browser-js'),
// bemtree // bemtree
// bemtree: require('enb-bemxjst/techs/bemtree'), // bemtree: require('enb-bemxjst/techs/bemtree'),
// bemhtml // bemhtml
bemhtml: require('enb-bemxjst/techs/bemhtml'), bemhtml: require('enb-bemxjst/techs/bemhtml'),
bemjsonToHtml: require('enb-bemxjst/techs/bemjson-to-html') bemjsonToHtml: require('enb-bemxjst/techs/bemjson-to-html'),
htmlBeautify: require('enb-beautify/techs/enb-beautify-html')
}, },
enbBemTechs = require('enb-bem-techs'), enbBemTechs = require('enb-bem-techs'),
merged = require('./techs/merged'), merged = require('./techs/merged'),
levels = [ levels = [
{ path: 'node_modules/bem-core/common.blocks', check: false }, { path: 'node_modules/bem-core/common.blocks', check: false },
{ path: 'node_modules/bem-core/desktop.blocks', check: false }, { path: 'node_modules/bem-core/desktop.blocks', check: false },
{ path: 'node_modules/bem-components/common.blocks', check: false }, { path: 'node_modules/bem-components/common.blocks', check: false },
{ path: 'node_modules/bem-components/desktop.blocks', check: false }, { path: 'node_modules/bem-components/desktop.blocks', check: false },
{ path: 'node_modules/bem-components/design/common.blocks', check: false }, { path: 'node_modules/bem-components/design/common.blocks', check: false },
{ path: 'node_modules/bem-components/design/desktop.blocks', check: false }, { path: 'node_modules/bem-components/design/desktop.blocks', check: false },
'common.blocks', 'common.blocks',
'desktop.blocks' 'desktop.blocks'
]; ];
module.exports = function(config) {module.exports = function(config) {
var isProd = process.env.YENV === 'production', var isProd = process.env.YENV === 'production',
mergedBundleName = 'merged', mergedBundleName = 'merged',
pathToMargedBundle = path.join('desktop.bundles', mergedBundleName); pathToMargedBundle = path.join('desktop.bundles', mergedBundleName);
fs.existsSync(pathToMargedBundle) || fs.mkdirSync(pathToMargedBundle); fs.existsSync(pathToMargedBundle) || fs.mkdirSync(pathToMargedBundle);
merged(config, pathToMargedBundle); merged(config, pathToMargedBundle);
config.nodes('*.bundles/*', function(nodeConfig) { config.nodes('*.bundles/*', function(nodeConfig) {
var isMergedNode = path.basename(nodeConfig.getPath()) === mergedBundleName; var isMergedNode = path.basename(nodeConfig.getPath()) === mergedBundleName;
isMergedNode || nodeConfig.addTechs([ isMergedNode || nodeConfig.addTechs([
[techs.fileProvider, { target: '?.bemjson.js' }], [techs.fileProvider, { target: '?.bemjson.js' }],
[enbBemTechs.bemjsonToBemdecl] [enbBemTechs.bemjsonToBemdecl]
]); ]);
nodeConfig.addTechs([ nodeConfig.addTechs([
// essential // essential
[enbBemTechs.levels, { levels: levels }], [enbBemTechs.levels, { levels: levels }],
[enbBemTechs.deps], [enbBemTechs.deps],
[enbBemTechs.files], [enbBemTechs.files],
// css // css
[techs.postcss, { [techs.postcss, {
target: '?.css', target: '?.css',
oneOfSourceSuffixes: ['post.css', 'css'], oneOfSourceSuffixes: ['post.css', 'css'],
plugins: techs.postcssPlugins plugins: techs.postcssPlugins
}], }],
// bemtree // bemtree
// [techs.bemtree, { sourceSuffixes: ['bemtree', 'bemtree.js'] }], // [techs.bemtree, { sourceSuffixes: ['bemtree', 'bemtree.js'] }],
// bemhtml // bemhtml
[techs.bemhtml, { [techs.bemhtml, {
sourceSuffixes: ['bemhtml', 'bemhtml.js'], sourceSuffixes: ['bemhtml', 'bemhtml.js'],
forceBaseTemplates: true, forceBaseTemplates: true,
engineOptions : { elemJsInstances : true } engineOptions : { elemJsInstances : true }
}], }],
// html // html
[techs.bemjsonToHtml], [techs.bemjsonToHtml],
[techs.htmlBeautify],
// client bemhtml // client bemhtml
[enbBemTechs.depsByTechToBemdecl, { [enbBemTechs.depsByTechToBemdecl, {
target: '?.bemhtml.bemdecl.js', target: '?.bemhtml.bemdecl.js',
sourceTech: 'js', sourceTech: 'js',
destTech: 'bemhtml' destTech: 'bemhtml'
}], }],
[enbBemTechs.deps, { [enbBemTechs.deps, {
target: '?.bemhtml.deps.js', target: '?.bemhtml.deps.js',
bemdeclFile: '?.bemhtml.bemdecl.js' bemdeclFile: '?.bemhtml.bemdecl.js'
}], }],
[enbBemTechs.files, { [enbBemTechs.files, {
depsFile: '?.bemhtml.deps.js', depsFile: '?.bemhtml.deps.js',
filesTarget: '?.bemhtml.files', filesTarget: '?.bemhtml.files',
dirsTarget: '?.bemhtml.dirs' dirsTarget: '?.bemhtml.dirs'
}], }],
[techs.bemhtml, { [techs.bemhtml, {
target: '?.browser.bemhtml.js', target: '?.browser.bemhtml.js',
filesTarget: '?.bemhtml.files', filesTarget: '?.bemhtml.files',
sourceSuffixes: ['bemhtml', 'bemhtml.js'], sourceSuffixes: ['bemhtml', 'bemhtml.js'],
engineOptions : { elemJsInstances : true } engineOptions : { elemJsInstances : true }
}], }],
// js // js
[techs.browserJs, { includeYM: true }], [techs.browserJs, { includeYM: true }],
[techs.fileMerge, { [techs.fileMerge, {
target: '?.js', target: '?.js',
sources: ['?.browser.js', '?.browser.bemhtml.js'] sources: ['?.browser.js', '?.browser.bemhtml.js']
}], }],
// borschik // borschik
[techs.borschik, { source: '?.js', target: '?.min.js', minify: isProd }], [techs.borschik, { source: '?.js', target: '?.min.js', minify: isProd }],
[techs.borschik, { source: '?.css', target: '?.min.css', minify: isProd }] [techs.borschik, { source: '?.css', target: '?.min.css', minify: isProd }]
]); ]);
nodeConfig.addTargets([/* '?.bemtree.js', */ '?.min.css', '?.min.js']); nodeConfig.addTargets([/* '?.bemtree.js', */ '?.min.css', '?.min.js']);
isMergedNode || nodeConfig.addTargets(['?.html']); isMergedNode || nodeConfig.addTargets(['?.html']);
}); });
};};
Editor
Original Text
Changed Text