grafana/tasks/build_task.js

70 lines
1.8 KiB
JavaScript
Raw Normal View History

2013-11-15 07:07:14 +08:00
module.exports = function(grunt) {
2015-01-05 00:51:48 +08:00
"use strict";
2013-11-15 07:07:14 +08:00
// Concat and Minify the src directory into dist
grunt.registerTask('build', [
'jshint:source',
'jshint:tests',
'karma:test',
2013-11-15 07:07:14 +08:00
'clean:on_start',
2014-02-11 01:05:52 +08:00
'less:src',
'concat:cssDark',
'concat:cssLight',
2013-11-15 07:07:14 +08:00
'copy:everything_but_less_to_temp',
'htmlmin:build',
'ngtemplates',
2013-11-15 07:07:14 +08:00
'cssmin:build',
'build:grafanaVersion',
2015-02-03 20:36:04 +08:00
'ngAnnotate:build',
2013-11-15 07:07:14 +08:00
'requirejs:build',
'concat:js',
'filerev',
'usemin',
2013-11-15 07:07:14 +08:00
'clean:temp',
//'uglify:dest'
2013-11-15 07:07:14 +08:00
]);
2015-01-01 22:28:28 +08:00
grunt.registerTask('build-post-process', function() {
var mode = grunt.config.get('mode');
if (mode === 'backend') {
grunt.config('copy.dist_to_tmp', {
expand: true,
cwd: '<%= destDir %>',
src: '**/*',
dest: '<%= tempDir %>/public/',
});
2015-01-05 00:51:48 +08:00
grunt.config('clean.dest_dir', ['<%= destDir %>']);
2015-01-01 22:28:28 +08:00
grunt.config('copy.backend_bin', {
cwd: 'bin',
2015-01-01 22:28:28 +08:00
expand: true,
src: ['grafana'],
options: { mode: true},
dest: '<%= tempDir %>'
});
grunt.config('copy.backend_files', {
2015-01-01 22:28:28 +08:00
expand: true,
src: ['conf/grafana.ini', 'vendor/**/*', 'scripts/*'],
options: { mode: true},
2015-01-01 22:28:28 +08:00
dest: '<%= tempDir %>'
});
grunt.task.run('copy:dist_to_tmp');
2015-01-05 00:51:48 +08:00
grunt.task.run('clean:dest_dir');
2015-01-01 22:28:28 +08:00
grunt.task.run('copy:backend_bin');
grunt.task.run('copy:backend_files');
2015-01-01 22:28:28 +08:00
}
});
grunt.registerTask('build:grafanaVersion', function() {
grunt.config('string-replace.config', {
files: {
'<%= tempDir %>/app/app.js': '<%= tempDir %>/app/app.js'
},
options: {
replacements: [{ pattern: /@grafanaVersion@/g, replacement: '<%= pkg.version %>' }]
}
2013-11-15 07:07:14 +08:00
});
grunt.task.run('string-replace:config');
2013-11-15 07:07:14 +08:00
});
};