Last active
January 3, 2016 10:39
-
-
Save sgimeno/8451156 to your computer and use it in GitHub Desktop.
A Gruntfile for Apache Cordova app development. Mimics Cordova CLI commands. Usage: ''grunt exec:<command>[:platform]".
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function ( grunt ) { | |
/** | |
* Load required Grunt tasks. These are installed based on the versions listed | |
* in `package.json` when you do `npm install` in this directory. | |
*/ | |
grunt.loadNpmTasks('grunt-contrib-watch'); | |
grunt.loadNpmTasks('grunt-exec'); | |
/** | |
* This is the configuration object Grunt uses to give each plugin its | |
* instructions. | |
*/ | |
var taskConfig = { | |
/** | |
* The 'watch' task watches the files modified during development and runs | |
* the Cordova 'prepare' task which will copy your 'www' folder to the | |
* platform specific build directory (ie: platforms/android/assets/www) | |
*/ | |
watch: { | |
scripts: { | |
files: [ | |
'www/*.html', | |
'www/js/**/*.js', | |
'www/css/**/*.css', | |
'www/spec/**/*.js', | |
'www/res/**/*.*', | |
'www/img/**/*.*', | |
], | |
tasks: ['prepare'], | |
options: { | |
spawn: false, | |
}, | |
}, | |
}, | |
exec: { | |
prepare: { | |
command: function(){ | |
return 'cordova prepare'; | |
} | |
}, | |
build: { | |
command: function(){ | |
return 'cordova build'; | |
} | |
}, | |
run: { | |
command: function(){ | |
return 'cordova run'; | |
} | |
} | |
} | |
}; | |
grunt.initConfig( grunt.util._.extend( taskConfig ) ); | |
grunt.registerTask( 'default', [ 'watch' ] ); | |
grunt.registerTask( 'prepare', ['exec:prepare'] ); | |
grunt.registerTask( 'build', ['prepare', 'exec:build' ] ); | |
grunt.registerTask( 'run', ['build', 'exec:run' ] ); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment