Commit 9c3cd87b by Torkel Ödegaard

more work on two grunt build modes, backend/standalone modes

parent f8ddfec9
......@@ -11,6 +11,19 @@ module.exports = function (grunt) {
docsDir: 'docs/'
};
config.mode = grunt.option('mode') || 'standalone';
config.modeOptions = {
requirejs: {
paths: { config: '../config.sample' },
excludeConfig: true,
}
};
if (config.mode === 'backend') {
config.modeOptions.requirejs.path = { config: 'components/config' };
config.modeOptions.requirejs.excludeConfig = true;
}
// load plugins
require('load-grunt-tasks')(grunt);
......@@ -34,5 +47,4 @@ module.exports = function (grunt) {
// pass the config to grunt
grunt.initConfig(config);
};
......@@ -64,6 +64,7 @@
"dependencies": {
"grunt-jscs-checker": "^0.4.4",
"karma-sinon": "^1.0.3",
"lodash": "^2.4.1",
"sinon": "^1.10.3"
}
}
......@@ -20,7 +20,7 @@ module.exports = function(grunt) {
'filerev',
'usemin',
'clean:temp',
// 'uglify:dest'
'uglify:dest'
]);
grunt.registerTask('build:grafanaVersion', function() {
......
module.exports = function(config,grunt) {
'use strict';
var _c = {
build: {
options: {
function buildRequireJsOptions() {
var options = {
appDir: '<%= tempDir %>',
dir: '<%= destDir %>',
mainConfigFile: '<%= tempDir %>/app/components/require.<%= mode %>.js',
baseUrl: './app',
paths: config.modeOptions.requirejs.paths,
mainConfigFile: '<%= tempDir %>/app/components/require.standalone.js',
modules: [], // populated below,
optimize: 'none',
optimizeCss: 'none',
optimizeAllPluginResources: false,
paths: { config: '../config.sample' }, // fix, fallbacks need to be specified
removeCombined: true,
findNestedDependencies: true,
normalizeDirDefines: 'all',
......@@ -34,12 +33,10 @@ module.exports = function(config,grunt) {
done();
}
}
}
};
// setup the modules require will build
var requireModules = _c.build.options.modules = [
var requireModules = options.modules = [
{
// main/common module
name: 'app',
......@@ -79,12 +76,17 @@ module.exports = function(config,grunt) {
requireModules[0].include.push('text!panels/'+panelName+'/module.html');
});
if (config.modeOptions.requirejs.excludeConfig) {
// exclude the literal config definition from all modules
requireModules
.forEach(function (module) {
module.excludeShallow = module.excludeShallow || [];
module.excludeShallow.push('config');
});
}
return { options: options };
}
return _c;
return { build: buildRequireJsOptions() };
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment