mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
feat(grunt watch): optimized grunt watch, now only operates on changed files
This commit is contained in:
parent
45c69fa638
commit
e194461420
@ -4,6 +4,7 @@ module.exports = function(config) {
|
||||
return {
|
||||
release: ['<%= destDir %>', '<%= tempDir %>', '<%= genDir %>'],
|
||||
gen: ['<%= genDir %>'],
|
||||
temp: ['<%= tempDir %>']
|
||||
temp: ['<%= tempDir %>'],
|
||||
css: ['<%= genDir %>/css']
|
||||
};
|
||||
};
|
||||
|
@ -1,39 +1,48 @@
|
||||
module.exports = function(config) {
|
||||
module.exports = function(config, grunt) {
|
||||
'use strict';
|
||||
|
||||
return {
|
||||
// css: {
|
||||
// files: [ '<%= srcDir %>/less#<{(||)}>#*.less' ],
|
||||
// tasks: ['css'],
|
||||
// options: {
|
||||
// spawn: false
|
||||
// }
|
||||
// },
|
||||
grunt.event.on('watch', function(action, filepath) {
|
||||
var newPath;
|
||||
|
||||
grunt.log.writeln('File Changed: ' + filepath);
|
||||
|
||||
if (/(\.html)$/.test(filepath)) {
|
||||
newPath = filepath.replace(/^public/, 'public_gen');
|
||||
grunt.log.writeln('Copying to ' + newPath);
|
||||
grunt.file.copy(filepath, newPath);
|
||||
}
|
||||
|
||||
if (/(\.js)$/.test(filepath)) {
|
||||
newPath = filepath.replace(/^public/, 'public_gen');
|
||||
grunt.log.writeln('Copying to ' + newPath);
|
||||
grunt.file.copy(filepath, newPath);
|
||||
|
||||
grunt.task.run('jshint');
|
||||
grunt.task.run('jscs');
|
||||
}
|
||||
|
||||
if (/(\.less)$/.test(filepath)) {
|
||||
grunt.task.run('clean:css');
|
||||
grunt.task.run('css');
|
||||
}
|
||||
|
||||
if (/(\.ts)$/.test(filepath)) {
|
||||
//changes changed file source to that of the changed file
|
||||
var option = 'typescript.build.src';
|
||||
var result = filepath;
|
||||
grunt.config(option, result);
|
||||
grunt.task.run('typescript:build');
|
||||
grunt.task.run('tslint');
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
copy_to_gen: {
|
||||
files: ['<%= srcDir %>/**/*'],
|
||||
tasks: [
|
||||
'clean:gen',
|
||||
'copy:public_to_gen',
|
||||
'css',
|
||||
'typescript:build',
|
||||
'jshint',
|
||||
'jscs',
|
||||
'tslint',
|
||||
'karma:test'
|
||||
],
|
||||
tasks: [],
|
||||
options: {
|
||||
spawn: false
|
||||
}
|
||||
},
|
||||
|
||||
// typescript: {
|
||||
// files: ['<%= srcDir %>/app#<{(||)}>#*.ts', '<%= srcDir %>/test#<{(||)}>#*.ts'],
|
||||
// tasks: ['tslint', 'typescript:build'],
|
||||
// options: {
|
||||
// spawn: false
|
||||
// }
|
||||
// }
|
||||
|
||||
};
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user