Unlike all of the other node projects i've written, this one needs the node server's folder to not be root. Here's the current folder hierarchy:
- Root/
- build/
- css/
- im/
- js/
- nodeserver/ <-- gruntfile and package are here
GruntFile.js
, package.json
, and server.js
are all located in nodeserver/
Here is my GruntFile:
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
uglify: {
files: {
'../build/all.min.js':['../js/config.js']
},
options: {
banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n',
report: true
}
}
});
// Load the plugin that provides the "uglify" task.
grunt.loadNpmTasks('grunt-contrib-uglify');
// Default task(s).
grunt.registerTask('default', ['uglify']);
};
When I run grunt, it can't find the file that I'm specifying. This is the response:
Running "uglify:files" (uglify) task
------------------------------------
Verifying property uglify.files exists in config...OK
File: [no files]
Options: banner="/*! demo-webservice 2014-03-28 */\n", footer="", compress={"warnings":false}, mangle={}, beautify=false, report
Why can't it see my js file?
Wrapping files: {}
in my_target: {}
solved my problem.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
uglify: {
my_target: {
files: {
'../build/all.min.js':['../js/config.js']
}
},
options: {
banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n',
report: true
}
}
});
^--- the new version of that initConfig.
It should also be noted that my_target
could be anything, and is used by default since it is the only uglify profile supplied. If i had supplied more than one profile, i.e. "test: {}, prod: {}, etc: {}", then I would refer to them after the task in the following way: uglify:test
, uglify:prod
, uglify:etc