build_task.js 1.3 KB

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