Created
October 11, 2012 19:44
-
-
Save peterssonjesper/3875019 to your computer and use it in GitHub Desktop.
Sample grunt configuration
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) { | |
grunt.initConfig({ | |
// Javascript minification | |
min : { | |
code : { | |
'src' : [ | |
'public/js/file1.js', | |
'public/js/file2.js', | |
'public/js/file3.js' | |
], | |
dest : 'build/js/min.js' | |
} | |
}, | |
// CSS minification | |
cssmin : { | |
theme : { | |
src : [ | |
'public/css/file1.css', | |
'public/css/file2.css', | |
'public/css/file3.css' | |
], | |
dest : 'build/css/min.css' | |
} | |
}, | |
// HTML minification | |
htmlcompressor : { | |
compile : { | |
files : [ | |
{ | |
src : 'public/index.php', | |
dest : 'build/index.php' | |
} | |
], | |
options : { | |
type: 'html', | |
preserveServerScript: true | |
} | |
} | |
}, | |
shell : { | |
// Create a build folder based on public, remove the javascript/css | |
createBuild : { | |
command : 'rm -rf build; cp -R public build; rm -rf build/css/*.css build/js/*;' | |
}, | |
// scp build/ to a remote host | |
publish : { | |
command : 'scp -r build remote_host:path/to/public' | |
} | |
} | |
}); | |
// Require needed grunt-modules | |
grunt.loadNpmTasks('grunt-sample'); | |
grunt.loadNpmTasks('grunt-css'); | |
grunt.loadNpmTasks('grunt-shell'); | |
grunt.loadNpmTasks('grunt-yui-compressor'); | |
grunt.loadNpmTasks('grunt-htmlcompressor'); | |
// Define tasks | |
grunt.registerTask('deploy', 'shell:createBuild cssmin min htmlcompressor'); | |
grunt.registerTask('publish', 'shell:publish') | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment