build_task.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. 'copy:everything_but_less_to_temp',
  9. 'htmlmin:build',
  10. 'cssmin:build',
  11. 'ngmin:build',
  12. 'requirejs:build',
  13. 'clean:temp',
  14. 'build:write_revision',
  15. 'uglify:dest'
  16. ]);
  17. // run a string replacement on the require config, using the latest revision number as the cache buster
  18. grunt.registerTask('build:write_revision', function() {
  19. grunt.event.once('git-describe', function (desc) {
  20. grunt.config('string-replace.config', {
  21. files: {
  22. '<%= destDir %>/app/components/require.config.js': '<%= destDir %>/app/components/require.config.js',
  23. '<%= destDir %>/app/app.js': '<%= destDir %>/app/app.js'
  24. },
  25. options: {
  26. replacements: [
  27. {
  28. pattern: /@REV@/g,
  29. replacement: desc.object
  30. },
  31. {
  32. pattern: /@grafanaVersion@/g,
  33. replacement: '<%= pkg.version %>'
  34. }
  35. ]
  36. }
  37. });
  38. grunt.task.run('string-replace:config');
  39. });
  40. grunt.task.run('git-describe');
  41. });
  42. };