requirejs.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. module.exports = function(config,grunt) {
  2. 'use strict';
  3. function buildRequireJsOptions() {
  4. var options = {
  5. appDir: '<%= tempDir %>',
  6. dir: '<%= destDir %>',
  7. mainConfigFile: '<%= tempDir %>/app/components/require.config.js',
  8. baseUrl: 'app_gen',
  9. waitSeconds: 0,
  10. modules: [], // populated below,
  11. optimize: 'none',
  12. optimizeCss: 'none',
  13. optimizeAllPluginResources: false,
  14. removeCombined: true,
  15. findNestedDependencies: true,
  16. normalizeDirDefines: 'all',
  17. inlineText: true,
  18. skipPragmas: true,
  19. done: function (done, output) {
  20. var duplicates = require('rjs-build-analysis').duplicates(output);
  21. if (duplicates.length > 0) {
  22. grunt.log.subhead('Duplicates found in requirejs build:');
  23. grunt.log.warn(duplicates);
  24. done(new Error('r.js built duplicate modules, please check the excludes option.'));
  25. }
  26. done();
  27. }
  28. };
  29. // setup the modules require will build
  30. var requireModules = options.modules = [
  31. {
  32. // main/common module
  33. name: 'app',
  34. include: [
  35. 'kbn',
  36. 'text',
  37. 'jquery',
  38. 'angular',
  39. 'settings',
  40. 'bootstrap',
  41. 'modernizr',
  42. 'timepicker',
  43. 'datepicker',
  44. 'lodash',
  45. 'jquery.flot',
  46. 'angular-strap',
  47. 'angular-dragdrop',
  48. 'services/all',
  49. 'features/all',
  50. 'directives/all',
  51. 'filters/all',
  52. 'controllers/all',
  53. 'routes/all',
  54. 'components/partials',
  55. // bundle the datasources
  56. 'plugins/datasource/grafana/datasource',
  57. 'plugins/datasource/graphite/datasource',
  58. 'plugins/datasource/influxdb_08/datasource',
  59. ]
  60. },
  61. // {
  62. // name: 'features/org/all',
  63. // exclude: ['app'],
  64. // }
  65. ];
  66. var fs = require('fs');
  67. var panelPath = config.srcDir+'/app/panels';
  68. // create a module for each directory in public/app/panels/
  69. fs.readdirSync(panelPath).forEach(function (panelName) {
  70. requireModules[0].include.push('panels/'+panelName+'/module');
  71. });
  72. return { options: options };
  73. }
  74. return { build: buildRequireJsOptions() };
  75. };