grafana/tasks/options/requirejs.js

83 lines
2.1 KiB
JavaScript
Raw Normal View History

2013-11-15 10:44:06 -06:00
module.exports = function(config,grunt) {
'use strict';
function buildRequireJsOptions() {
2013-11-14 17:07:14 -06:00
var options = {
2015-09-10 05:42:24 -05:00
appDir: '<%= genDir %>',
dir: '<%= tempDir %>',
mainConfigFile: '<%= genDir %>/app/components/require.config.js',
baseUrl: './',
2015-08-17 14:41:04 -05:00
waitSeconds: 0,
2013-11-14 17:07:14 -06:00
modules: [], // populated below,
2013-11-14 17:07:14 -06:00
optimize: 'none',
optimizeCss: 'none',
optimizeAllPluginResources: false,
removeCombined: true,
findNestedDependencies: true,
normalizeDirDefines: 'all',
inlineText: true,
skipPragmas: true,
2013-11-14 17:07:14 -06:00
done: function (done, output) {
var duplicates = require('rjs-build-analysis').duplicates(output);
2013-11-14 17:07:14 -06:00
if (duplicates.length > 0) {
grunt.log.subhead('Duplicates found in requirejs build:');
grunt.log.warn(duplicates);
done(new Error('r.js built duplicate modules, please check the excludes option.'));
2013-11-14 17:07:14 -06:00
}
done();
2013-11-14 17:07:14 -06:00
}
};
2013-11-14 17:07:14 -06:00
// setup the modules require will build
var requireModules = options.modules = [
2015-09-10 04:26:40 -05:00
{
// main/common module
name: 'app/app',
include: [
'kbn',
'text',
'jquery',
'angular',
'settings',
'bootstrap',
'modernizr',
'timepicker',
'datepicker',
'lodash',
'jquery.flot',
'angular-strap',
'angular-dragdrop',
'app/core/core',
'app/services/all',
'app/features/all',
'app/controllers/all',
'app/components/partials',
// bundle the datasources
'app/plugins/datasource/grafana/datasource',
'app/plugins/datasource/graphite/datasource',
'app/plugins/datasource/influxdb/datasource',
]
2015-09-10 04:26:40 -05:00
},
];
2013-11-15 10:44:06 -06:00
var fs = require('fs');
var panelPath = config.srcDir + '/app/panels';
2013-11-14 17:07:14 -06:00
// create a module for each directory in public/app/panels/
fs.readdirSync(panelPath).forEach(function (panelName) {
requireModules[0].include.push('app/panels/'+panelName+'/module');
2013-11-14 17:07:14 -06:00
});
return { options: options };
}
return { build: buildRequireJsOptions() };
2013-11-14 17:07:14 -06:00
};