grunt uglify task failing-Collection of common programming errors
I know this is marked as solved, but I still prefer this answer from a similar question because you can easily use the files again for another command without writing them twice.
Basically, the answer says
//Does not work
src: ['client/src/js/*.js'],
dest: ['client/dist/js/build.js']
//Works
src: ['client/src/js/*.js'],
dest: 'client/dist/js/build.js'
Tested working example without writing files twice:
'use strict';
module.exports = function(grunt) {
grunt.initConfig({
uglify: {
build: {
src: ['client/src/js/*.js'],
dest: 'client/dist/js/build.js'
}
},
watch: {
js: {
files: '',
tasks: ['uglify']
}
}
});
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.registerTask('default', [
'uglify',
]);
grunt.registerTask('dev', [
'watch'
]);
};
Notice that ''
is very handy 😉
Execution
$ grunt watch
Running "watch" task
Waiting...OK
>> File "client/src/js/hello.js" changed.
Running "uglify:build" (uglify) task
File "client/dist/js/build.js" created.
Uncompressed size: 15 bytes.
Compressed size: 32 bytes gzipped (15 bytes minified).
Done, without errors.