Created
March 9, 2017 00:18
-
-
Save tmosest/9a9b118cd60ccebcfe2ed7eba0e452a4 to your computer and use it in GitHub Desktop.
Example of a grunt file
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) { | |
//1. Configurations | |
grunt.initConfig({ | |
pkg: grunt.file.readJSON('package.json'), | |
coffee: { | |
dist: { | |
files: { | |
'src/js/global.js': 'src/coffee/global.coffee' | |
} | |
} | |
}, | |
/* Need to have ruby and haml installed */ | |
haml: { | |
dist: { | |
files: { | |
'tmosest.php': 'src/haml/tmosest.haml' | |
} | |
} | |
}, | |
/* Need to have ruby and sass installed */ | |
sass: { | |
dist: { | |
files: { | |
'src/css/stylesheet.css': 'src/sass/main.sass' | |
} | |
} | |
}, | |
less: { | |
dist: { | |
files: { | |
'src/css/stylesheet.css': 'src/less/stylesheet.less' | |
} | |
} | |
}, | |
concat: { | |
libs: { | |
src: 'src/js/libs/*.js', | |
dest: 'src/js/_libs.js' | |
}, | |
app: { | |
src: 'src/js/app/**/*.js', | |
dest: 'src/js/app.js' | |
}, | |
appLess: { | |
src: 'src/js/app/**/*.less', | |
dest: 'src/less/app.less' | |
}, | |
js: { | |
src: 'src/js/*.js', | |
dest: 'js/main.js' | |
}, | |
css: { | |
src: 'src/css/*.css', | |
dest: 'css/main.css' | |
} | |
}, | |
uglify: { | |
build: { | |
src: "js/main.js", | |
dest: "js/main.min.js" | |
} | |
}, | |
cssmin: { | |
css: { | |
src: "css/main.css", | |
dest: "css/main.min.css" | |
} | |
}, | |
watch: { | |
haml: { | |
files: ["src/haml/*.haml"], | |
tasks: ["haml"] | |
}, | |
css: { | |
files: ["src/css/*.css"], | |
tasks: ["concat:css", "cssmin"] | |
}, | |
less: { | |
files: ["src/less/**/*.less"], | |
tasks: ["less"] | |
}, | |
sass: { | |
files: ["src/sass/*.sass"], | |
tasks: ["sass"] | |
}, | |
js: { | |
files: ["src/js/**/*.js"], | |
tasks: ["concat:libs", "concat:js", "uglify"] | |
}, | |
coffee: { | |
files: ["src/coffee/*.coffee"], | |
tasks: ["coffee"] | |
} | |
} | |
}); | |
//3. Load packages | |
grunt.loadNpmTasks('grunt-contrib-coffee'); | |
grunt.loadNpmTasks('grunt-contrib-concat'); | |
grunt.loadNpmTasks('grunt-contrib-haml'); | |
grunt.loadNpmTasks('grunt-contrib-less'); | |
grunt.loadNpmTasks('grunt-contrib-sass'); | |
grunt.loadNpmTasks('grunt-contrib-uglify'); | |
grunt.loadNpmTasks('grunt-contrib-watch'); | |
grunt.loadNpmTasks('grunt-css'); | |
//4. Add it to default grunt task | |
grunt.registerTask('default', ['concat:appLess', 'less', 'concat', 'uglify', 'cssmin']); | |
grunt.registerTask('watchham', ['watch:haml']); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment