Skip to content

Instantly share code, notes, and snippets.

@delfrrr delfrrr/enb-make.js
Created May 13, 2015

Embed
What would you like to do?
/**
* build setup
* @see https://github.com/enb-make/enb
*/
module.exports = function (config) {
var levels = [
'node_modules/bem-node/node_modules/bem-bl/blocks-common',
'node_modules/bem-node/node_modules/bem-bl/blocks-desktop',
'node_modules/bem-node/node_modules/bem-json',
'node_modules/bem-node/blocks',
'blocks'
],
getLevels = function () {
return levels.map(function (path) {
return config.resolvePath(path);
});
},
build = require('enb/lib/build-flow'),
cwd = process.cwd(),
makeRequires = function () {
return Array.prototype.map.call(arguments, function (arg) {
if (typeof arg === 'string') {
return 'require(\'' + arg.replace(cwd, '../..') + '\');';
} else if (Array.isArray(arg)) {
return makeRequires.apply(null, arg.map(function (file) {
return file && file.fullname;
}));
} else {
return '';
}
}).join('\n') + '\n';
},
server = build.create()
.name('server.js')
.target('target', '?.server.js')
.useFileList('server.js')
.builder(makeRequires)
.createTech(),
priv = build.create()
.name('priv.js')
.target('target', '?.priv.js')
.useFileList(['common.js', 'priv.js'])
.builder(makeRequires)
.createTech(),
js = build.create()
.name('js')
.target('target', '_?.js')
.useFileList(['common.js', 'js'])
.justJoinFilesWithComments()
.useSourceFilename('templates', '?.bemhtml.js')
.createTech();
config.node('app/bikery', function (nodeConfig) {
nodeConfig.addTechs([
[ require('enb-bem-techs/techs/levels'), { levels: getLevels(config) } ],
[ require('enb/techs/file-provider'), { target: '?.bemdecl.js' } ],
[require('enb-bemhtml/techs/bemhtml')],
require('./techs/deps-old'),
require('./techs/files'),
require('./techs/css-less'),
server,
priv,
js,
[ require('enb-borschik/techs/borschik'), { sourceTarget: '_?.js', destTarget: '?.js', minify: false}]
]);
nodeConfig.addTargets([
'?.server.js',
'?.priv.js',
'?.js',
'?.css',
'?.bemhtml.js'
]);
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.