Reputation: 424
I am new to using grunt. I am not been able to use grunt watch. Following is my grunt file:
module.exports = function(grunt) {
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
uglify: {
my_target: {
files: {
'public/admin/js/developer.min.js': ['public/admin/js/developer.js']
}
}
},
cssmin: {
target: {
files: {
'public/admin/css/developer2.min.css': ['public/admin/css/developer.css']
}
}
},
csslint: {
strict: {
options: {
import: 2
},
src: ['public/admin/css/developer.css']
},
lax: {
options: {
import: false
},
src: ['public/admin/css/developer.css']
}
},
htmlhint: {
html1: {
options: {
'tag-pair': true
},
src: ['app/views/admin/property/*.php']
}
},
jshint: {
all: ['Gruntfile.js', 'public/admin/js/developer.js'],
options: {
reporter: require('jshint-stylish')
}
},
jslint: { // configure the task
// lint your project's client code
client: {
src: [
'public/admin/js/developer.js'
],
directives: {
browser: true,
predef: [
'jQuery'
]
},
options: {
junit: 'out/client-junit.xml'
}
}
},
qunit: {
qunit: {
all: {
options: {
urls: [
'http://localhost:8000/tests/TestCase.php',
'http://localhost:8000/tests/ExampleTest.php'
]
}
}
}
},
jsvalidate: {
options:{
globals: {},
esprimaOptions: {},
verbose: false
},
targetName:{
files:{
src:['public/admin/js/*.js']
}
}
},
watch: {
files: 'public/admin/js/*.js',
task: ['uglify'],
options: {
nospawn: false
},
},
});
// Load the plugin that provides the "uglify" task.
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-csslint');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-jslint');
grunt.loadNpmTasks('grunt-jsvalidate');
grunt.loadNpmTasks('grunt-htmlhint');
grunt.loadNpmTasks('grunt-contrib-qunit');
grunt.loadNpmTasks('grunt-contrib-watch');
// Default task(s).
grunt.registerTask('default', ['uglify'],['cssmin'],['csslint'],['jshint'],['jslint'],['htmlhint'],['jsvalidate'],['qunit'],['watch']);
};
I am trying to run 'uglify' task when there is any change in my .js files but it ain't happening. All I get is the following screen it stuck here . Kindly help me running this grunt task. Thank you!!
Upvotes: 0
Views: 475
Reputation: 1213
You made a small typo. Instead of "task" inside the watch configuration block it should be "tasks"
watch: {
files: 'public/admin/js/*.js',
tasks: ['uglify'],
options: {
nospawn: false
},
},
Source: https://github.com/gruntjs/grunt-contrib-watch
Upvotes: 1