build_task.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. module.exports = function(grunt) {
  2. // Concat and Minify the src directory into dist
  3. grunt.registerTask('build', [
  4. 'jshint:source',
  5. 'jshint:tests',
  6. 'clean:on_start',
  7. 'less:src',
  8. 'concat:css',
  9. 'copy:everything_but_less_to_temp',
  10. 'htmlmin:build',
  11. 'ngtemplates:app',
  12. 'cssmin:build',
  13. 'ngmin:build',
  14. 'requirejs:build',
  15. 'clean:temp',
  16. 'build:write_revision',
  17. 'uglify:dest'
  18. ]);
  19. // run a string replacement on the require config, using the latest revision number as the cache buster
  20. grunt.registerTask('build:write_revision', function() {
  21. grunt.event.once('git-describe', function (desc) {
  22. grunt.config('string-replace.config', {
  23. files: {
  24. '<%= destDir %>/app/components/require.config.js': '<%= destDir %>/app/components/require.config.js',
  25. '<%= destDir %>/app/app.js': '<%= destDir %>/app/app.js'
  26. },
  27. options: {
  28. replacements: [
  29. {
  30. pattern: /@REV@/g,
  31. replacement: desc.object
  32. },
  33. {
  34. pattern: /@grafanaVersion@/g,
  35. replacement: '<%= pkg.version %>'
  36. }
  37. ]
  38. }
  39. });
  40. grunt.task.run('string-replace:config');
  41. });
  42. grunt.task.run('git-describe');
  43. });
  44. };