systemjs_task.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. module.exports = function(grunt) {
  2. "use strict";
  3. grunt.registerTask('systemjs:build', function() {
  4. var path = require('path');
  5. var Builder = require('systemjs-builder');
  6. var done = this.async();
  7. // optional constructor options
  8. // sets the baseURL and loads the configuration file
  9. var builder = new Builder('public_gen', 'public_gen/app/system.conf.js');
  10. console.log('Starting systemjs-builder');
  11. var modules = [
  12. 'app/app',
  13. 'app/features/all',
  14. 'app/plugins/panel/**/module',
  15. 'app/plugins/datasource/graphite/module',
  16. 'app/plugins/datasource/influxdb/module',
  17. 'app/plugins/datasource/elasticsearch/module',
  18. ];
  19. var expression = modules.join(' + ');
  20. builder
  21. .bundle(expression, 'public_gen/app/app_bundle.js')
  22. .then(function(res) {
  23. console.log('Build complete', res.modules);
  24. for (var i = 0; i < res.modules.length; i++) {
  25. var modulePath = path.join('public_gen', res.modules[i]);
  26. console.log(modulePath);
  27. grunt.file.delete(modulePath);
  28. }
  29. done();
  30. grunt.task.run('concat:bundle_and_boot');
  31. })
  32. .catch(function(err) {
  33. console.log('Build error');
  34. console.log(err);
  35. done(false);
  36. });
  37. });
  38. };