b925f472 by Adam Heath

Add build:foo feature flag support.

1 parent efcdde5f
......@@ -37,9 +37,6 @@ module.exports = function (grunt) {
lines.push('container[' + JSON.stringify(id) + ']=' + JSON.stringify(file) + ';\n');
});
lines.push('})(require.paths);');
if (false && lines.length == 2) {
lines = [];
}
grunt.file.write('.grunt/holygrail/scripts/revconfig.js', lines.join(''));
});
......@@ -49,7 +46,7 @@ module.exports = function (grunt) {
var holyGrailTmp = '.grunt/holygrail';
var initConfig = {
clean: {
dist: {
montyPython: {
files: [{
dot: true,
src: [
......@@ -88,8 +85,14 @@ module.exports = function (grunt) {
var checkList = [];
var buildList = [
'check',
'clean:dist',
'clean:montyPython',
'post-clean',
];
var postCleanList = [];
grunt.registerTask('post-clean', 'post-clean', function() {
grunt.task.run(postCleanList);
});
function externalMultiTask(name, desc, command, updateOptions) {
grunt.log.writeln('registering multiTask', name);
......@@ -236,7 +239,7 @@ module.exports = function (grunt) {
src: ['dist/!(scripts){,**/}*.html'],
},
};
initConfig.clean.dist.files[0].src.push('.grunt/usemin');
initConfig.clean.montyPython.files[0].src.push('.grunt/usemin');
initConfig.htmlmin = {
dist: {
//options: _.extend({}, mpConfig.htmlmin.options),
......@@ -262,7 +265,7 @@ module.exports = function (grunt) {
}),
}]
};
initConfig.clean.dist.files[0].src.push('.grunt/usemin-css');
initConfig.clean.montyPython.files[0].src.push('.grunt/usemin-css');
initConfig.usemin.css = _.map(mpConfig.css.options.dirs, function (value) {
return 'dist/' + value + '/{,**/}*.css';
});
......@@ -367,7 +370,6 @@ module.exports = function (grunt) {
initConfig.requirejs = {
dist: {
options: {
done: function onDone(next) {
/* jshint devel:true */
var target = grunt.task.current.target;
......@@ -390,7 +392,7 @@ module.exports = function (grunt) {
}
//lines.push('return bundles;');
lines.push('})(require, \'bundles\');');
if (lines.length == 2) {
if (lines.length == 3) {
lines = [];
}
grunt.file.write('.grunt/holygrail/scripts/bundles.js', lines.join('\n'));
......@@ -459,9 +461,6 @@ module.exports = function (grunt) {
}
//buildList.push('uglify:bower'); // montyPython
//buildList.push('uglify:requireconfig'); // montyPython
if (mpConfig.useRev && mpConfig.bower) {
//buildList.push('rev:requireconfig'); // montyPython
}
buildList.push('usemin:html'); // montyPython
buildList.push('usemin:css'); // montyPython
buildList.push('htmlmin'); // montyPython
......@@ -474,7 +473,32 @@ module.exports = function (grunt) {
'check',
]);
grunt.registerTask('build', buildList);
grunt.registerTask('build', 'build the system', function() {
var featureFlags = {};
if (arguments.length) {
for (var i in arguments) {
featureFlags['BUILD_' + arguments[i].toUpperCase()] = true;
}
grunt.registerTask('writeFeatureFlags', 'write feature flags', function() {
var lines = [
'(function(container, propName) {',
'container = (container[propName] = container[propName] || {});',
];
for (var flag in featureFlags) {
lines.push('require.config.featureFlags[' + JSON.stringify(flag) + ']=' + JSON.stringify(featureFlags[flag]) + ';');
}
//lines.push('return bundles;');
lines.push('})(require.config, \'featureFlags\');');
if (lines.length == 3) {
lines = [];
}
grunt.file.write('.grunt/holygrail/scripts/featureFlags.js', lines.join('\n'));
});
postCleanList.add('writeFeatureFlags');
}
grunt.task.run(buildList);
});
}
return {
......