grafana/tasks/options/requirejs.js

85 lines
2.2 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 = {
appDir: '<%= tempDir %>',
dir: '<%= destDir %>',
mainConfigFile: '<%= tempDir %>/app/components/require.config.js',
baseUrl: './app',
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 = [
2013-11-14 17:07:14 -06:00
{
// main/common module
name: 'app',
include: [
'kbn',
'text',
'jquery',
'angular',
'settings',
'bootstrap',
'modernizr',
'timepicker',
'datepicker',
'lodash',
'jquery.flot',
'angular-strap',
'angular-dragdrop',
'services/all',
'features/all',
'directives/all',
'filters/all',
'controllers/all',
'routes/all',
'components/partials',
// bundle the datasources
'plugins/datasource/grafana/datasource',
'plugins/datasource/graphite/datasource',
'plugins/datasource/influxdb_08/datasource',
]
}
];
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('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
};