Skip to content

Instantly share code, notes, and snippets.

@burakcan
Last active August 29, 2015 14:14
Show Gist options
  • Save burakcan/b8b3f22120716ce66c87 to your computer and use it in GitHub Desktop.
Save burakcan/b8b3f22120716ce66c87 to your computer and use it in GitHub Desktop.
module.exports = function(grunt) {
var _serve = grunt.option('serve') || false;
var _devTasks = ['copy', 'browserify', 'compass', 'concurrent'];
var _concurrentTasks = ['watch']
var _watcherTasks = {
htmls : ['copy:htmls'],
styles : ['compass'],
images : ['copy:images'],
scripts : ['browserify']
}
if(_serve){ _concurrentTasks.push('connect') }
grunt.initConfig({
pkg : grunt.file.readJSON('package.json'),
concurrent : {
target : {
tasks : _concurrentTasks,
options : {
logConcurrentOutput : true
}
}
},
browserify : {
'./dist/js/main.js': ['./src/scripts/main.js']
},
copy : {
fonts : {
expand : true,
cwd : './src/fonts',
src : ['**/*'],
dest : './dist/fonts/'
},
images : {
expand : true,
cwd : './src/images',
src : ['**/*', '!**/sprite/**', '!**/sprite@2x/**'],
dest : './dist/images/'
},
vendor : {
expand : true,
cwd : './src/vendor',
src : ['**/*'],
dest : './dist/vendor/'
},
htmls : {
expand : true,
cwd : './src/htmls',
src : ['**/*'],
dest : './dist/'
}
},
connect : {
server : {
options : {
port : 1992,
base : './dist',
keepalive : true
}
}
},
compass : {
dev : {
options : {
sassDir : './src/styles',
cssDir : './dist/css',
imagesDir : 'images',
cssPath : './dist/css',
imagesPath: './src/images',
generatedImagesDir : './dist/images',
generatedImagesPath: './dist/images'
}
}
},
watch : {
htmls : {
files : ['./src/htmls/**/*.html'],
tasks : _watcherTasks.htmls
},
scripts : {
files : ['./src/scripts/**/*.js'],
tasks : _watcherTasks.scripts
},
images : {
files : ['./src/images/**/*', '!./src/images/sprite/*'],
tasks : _watcherTasks.images
},
styles : {
files : ['./src/styles/style.sass'],
tasks : _watcherTasks.styles
}
}
});
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-concurrent');
grunt.loadNpmTasks('grunt-browserify');
grunt.loadNpmTasks('grunt-contrib-compass');
grunt.registerTask('dev', _devTasks);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment