Skip to content

Instantly share code, notes, and snippets.

@ericvicenti
Created February 11, 2014 04:43
Show Gist options
  • Save ericvicenti/8929388 to your computer and use it in GitHub Desktop.
Save ericvicenti/8929388 to your computer and use it in GitHub Desktop.
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
browserify: {
app_build: {
options: {
debug: true,
global: true, // all transforms happen on al files
transform: [ 'reactify', 'es6ify' ]
},
cwd: '.',
src: 'src/main.jsx',
dest: 'dist-dev/script/main.js',
}
},
uglify: {
options: {
banner: '/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %> */\n'
},
app_build: {
files: {
'dist/script/main.js': [ 'dist-dev/script/main.js' ]
}
}
},
clean: {
build: [ 'build' ],
dist: [ 'dist' ],
dist_dev: [ 'dist-dev' ],
mobile_www: [ 'mobile/www' ]
},
watch: {
develop: {
files: [ '**/*.js', '**/*.jsx' ],
tasks: [ 'build' ],
options: {
cwd: 'src',
spawn: false,
livereload: true
}
}
},
nodemon: {
develop: {
script: '../main.js',
options: {
cwd: 'src',
// ignoredFiles: ['node_modules/**'],
// nodeArgs: [ '--debug' ],
watchedExtensions: ['js', 'jsx'],
delayTime: 3,
env: {
// PORT: '8069'
}
}
}
},
exec:{
ios_run:{
cwd: './mobile',
command:"phonegap run ios",
stdout:true,
stderror:true
}
},
copy: {
mobile_public: {
files: [
{expand: true, cwd: 'public/', src: ['**'], dest: 'mobile/www/'},
]
},
mobile_dist: {
files: [
{expand: true, cwd: 'dist/', src: ['**'], dest: 'mobile/www/'},
]
},
mobile_public_mobile: {
files: [
{expand: true, cwd: 'public-mobile/', src: ['**'], dest: 'mobile/www/'},
]
},
},
concurrent: {
develop: {
tasks: [
'nodemon:develop',
'watch:develop'
],
options: {
logConcurrentOutput: true
}
}
},
});
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-concurrent');
grunt.loadNpmTasks('grunt-nodemon');
grunt.loadNpmTasks('grunt-browserify');
grunt.loadNpmTasks('grunt-exec');
grunt.registerTask('build', [
'clean:dist',
'clean:dist_dev',
'clean:build',
'browserify:app_build',
'uglify:app_build',
'clean:build'
]);
grunt.registerTask('ios', [
'build',
'clean:mobile_www',
'copy:mobile_public',
'copy:mobile_dist',
'copy:mobile_public_mobile',
'exec:ios_run'
])
grunt.registerTask('develop', [ 'build', 'concurrent:develop' ]);
grunt.registerTask('default', [ 'build' ]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment