Last active
August 29, 2015 14:26
-
-
Save niktayv/2e0014eaa19b40d56253 to your computer and use it in GitHub Desktop.
These are the files from Landon Schropp's Grunt tutorial: http://www.sitepoint.com/writing-awesome-build-script-grunt/
This file contains hidden or 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 = (grunt) -> | |
| # configure the tasks | |
| grunt.initConfig | |
| copy: | |
| build: | |
| cwd: "source" | |
| src: [ | |
| "**" | |
| "!**/*.styl" | |
| "!**/*.coffee" | |
| "!**/*.jade" | |
| ] | |
| dest: "build" | |
| expand: true | |
| clean: | |
| build: | |
| src: ["build"] | |
| stylesheets: | |
| src: [ | |
| "build/**/*.css" | |
| "!build/application.css" | |
| ] | |
| scripts: | |
| src: [ | |
| "build/**/*.js" | |
| "!build/application.js" | |
| ] | |
| stylus: | |
| build: | |
| options: | |
| linenos: true | |
| compress: false | |
| files: [ | |
| expand: true | |
| cwd: "source" | |
| src: ["**/*.styl"] | |
| dest: "build" | |
| ext: ".css" | |
| ] | |
| autoprefixer: | |
| build: | |
| expand: true | |
| cwd: "build" | |
| src: ["**/*.css"] | |
| dest: "build" | |
| cssmin: | |
| build: | |
| files: | |
| "build/application.css": ["build/**/*.css"] | |
| coffee: | |
| build: | |
| expand: true | |
| cwd: "source" | |
| src: ["**/*.coffee"] | |
| dest: "build" | |
| ext: ".js" | |
| uglify: | |
| build: | |
| options: | |
| mangle: false | |
| files: | |
| "build/application.js": ["build/**/*.js"] | |
| jade: | |
| compile: | |
| options: | |
| data: {} | |
| files: [ | |
| expand: true | |
| cwd: "source" | |
| src: ["**/*.jade"] | |
| dest: "build" | |
| ext: ".html" | |
| ] | |
| watch: | |
| stylesheets: | |
| files: "source/**/*.styl" | |
| tasks: ["stylesheets"] | |
| scripts: | |
| files: "source/**/*.coffee" | |
| tasks: ["scripts"] | |
| jade: | |
| files: "source/**/*.jade" | |
| tasks: ["jade"] | |
| copy: | |
| files: [ | |
| "source/**" | |
| "!source/**/*.styl" | |
| "!source/**/*.coffee" | |
| "!source/**/*.jade" | |
| ] | |
| tasks: ["copy"] | |
| connect: | |
| server: | |
| options: | |
| port: 4000 | |
| base: "build" | |
| hostname: "*" | |
| # load the tasks | |
| grunt.loadNpmTasks "grunt-contrib-copy" | |
| grunt.loadNpmTasks "grunt-contrib-clean" | |
| grunt.loadNpmTasks "grunt-contrib-stylus" | |
| grunt.loadNpmTasks "grunt-autoprefixer" | |
| grunt.loadNpmTasks "grunt-contrib-cssmin" | |
| grunt.loadNpmTasks "grunt-contrib-coffee" | |
| grunt.loadNpmTasks "grunt-contrib-uglify" | |
| grunt.loadNpmTasks "grunt-contrib-jade" | |
| grunt.loadNpmTasks "grunt-contrib-watch" | |
| grunt.loadNpmTasks "grunt-contrib-connect" | |
| # define the tasks | |
| grunt.registerTask "stylesheets", "Compiles the stylesheets.", [ | |
| "stylus" | |
| "autoprefixer" | |
| "cssmin" | |
| "clean:stylesheets" | |
| ] | |
| grunt.registerTask "scripts", "Compiles the JavaScript files.", [ | |
| "coffee" | |
| "uglify" | |
| "clean:scripts" | |
| ] | |
| grunt.registerTask "build", "Compiles all of the assets and copies the files to the build directory.", [ | |
| "clean:build" | |
| "copy" | |
| "stylesheets" | |
| "scripts" | |
| "jade" | |
| ] | |
| grunt.registerTask "default", "Watches the project for changes, automatically builds them and runs a server.", [ | |
| "build" | |
| "connect" | |
| "watch" | |
| ] | |
| return |
This file contains hidden or 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) { | |
| // configure the tasks | |
| grunt.initConfig({ | |
| copy: { | |
| build: { | |
| cwd: 'source', | |
| src: [ '**', '!**/*.styl', '!**/*.coffee', '!**/*.jade' ], | |
| dest: 'build', | |
| expand: true | |
| }, | |
| }, | |
| clean: { | |
| build: { | |
| src: [ 'build' ] | |
| }, | |
| stylesheets: { | |
| src: [ 'build/**/*.css', '!build/application.css' ] | |
| }, | |
| scripts: { | |
| src: [ 'build/**/*.js', '!build/application.js' ] | |
| }, | |
| }, | |
| stylus: { | |
| build: { | |
| options: { | |
| linenos: true, | |
| compress: false | |
| }, | |
| files: [{ | |
| expand: true, | |
| cwd: 'source', | |
| src: [ '**/*.styl' ], | |
| dest: 'build', | |
| ext: '.css' | |
| }] | |
| } | |
| }, | |
| autoprefixer: { | |
| build: { | |
| expand: true, | |
| cwd: 'build', | |
| src: [ '**/*.css' ], | |
| dest: 'build' | |
| } | |
| }, | |
| cssmin: { | |
| build: { | |
| files: { | |
| 'build/application.css': [ 'build/**/*.css' ] | |
| } | |
| } | |
| }, | |
| coffee: { | |
| build: { | |
| expand: true, | |
| cwd: 'source', | |
| src: [ '**/*.coffee' ], | |
| dest: 'build', | |
| ext: '.js' | |
| } | |
| }, | |
| uglify: { | |
| build: { | |
| options: { | |
| mangle: false | |
| }, | |
| files: { | |
| 'build/application.js': [ 'build/**/*.js' ] | |
| } | |
| } | |
| }, | |
| jade: { | |
| compile: { | |
| options: { | |
| data: {} | |
| }, | |
| files: [{ | |
| expand: true, | |
| cwd: 'source', | |
| src: [ '**/*.jade' ], | |
| dest: 'build', | |
| ext: '.html' | |
| }] | |
| } | |
| }, | |
| watch: { | |
| stylesheets: { | |
| files: 'source/**/*.styl', | |
| tasks: [ 'stylesheets' ] | |
| }, | |
| scripts: { | |
| files: 'source/**/*.coffee', | |
| tasks: [ 'scripts' ] | |
| }, | |
| jade: { | |
| files: 'source/**/*.jade', | |
| tasks: [ 'jade' ] | |
| }, | |
| copy: { | |
| files: [ 'source/**', '!source/**/*.styl', '!source/**/*.coffee', '!source/**/*.jade' ], | |
| tasks: [ 'copy' ] | |
| } | |
| }, | |
| connect: { | |
| server: { | |
| options: { | |
| port: 4000, | |
| base: 'build', | |
| hostname: '*' | |
| } | |
| } | |
| } | |
| }); | |
| // load the tasks | |
| grunt.loadNpmTasks('grunt-contrib-copy'); | |
| grunt.loadNpmTasks('grunt-contrib-clean'); | |
| grunt.loadNpmTasks('grunt-contrib-stylus'); | |
| grunt.loadNpmTasks('grunt-autoprefixer'); | |
| grunt.loadNpmTasks('grunt-contrib-cssmin'); | |
| grunt.loadNpmTasks('grunt-contrib-coffee'); | |
| grunt.loadNpmTasks('grunt-contrib-uglify'); | |
| grunt.loadNpmTasks('grunt-contrib-jade'); | |
| grunt.loadNpmTasks('grunt-contrib-watch'); | |
| grunt.loadNpmTasks('grunt-contrib-connect'); | |
| // define the tasks | |
| grunt.registerTask( | |
| 'stylesheets', | |
| 'Compiles the stylesheets.', | |
| [ 'stylus', 'autoprefixer', 'cssmin', 'clean:stylesheets' ] | |
| ); | |
| grunt.registerTask( | |
| 'scripts', | |
| 'Compiles the JavaScript files.', | |
| [ 'coffee', 'uglify', 'clean:scripts' ] | |
| ); | |
| grunt.registerTask( | |
| 'build', | |
| 'Compiles all of the assets and copies the files to the build directory.', | |
| [ 'clean:build', 'copy', 'stylesheets', 'scripts', 'jade' ] | |
| ); | |
| grunt.registerTask( | |
| 'default', | |
| 'Watches the project for changes, automatically builds them and runs a server.', | |
| [ 'build', 'connect', 'watch' ] | |
| ); | |
| }; |
This file contains hidden or 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
| { | |
| "name": "grunt_tutorial", | |
| "description": "An example of how to set up Grunt for web development.", | |
| "author": "Landon Schropp (http://landonschropp.com)", | |
| "dependencies": { | |
| "grunt": "0.x.x", | |
| "grunt-autoprefixer": "0.2.x", | |
| "grunt-contrib-clean": "0.5.x", | |
| "grunt-contrib-coffee": "0.7.x", | |
| "grunt-contrib-connect": "0.4.x", | |
| "grunt-contrib-copy": "0.4.x", | |
| "grunt-contrib-cssmin": "0.6.x", | |
| "grunt-contrib-jade": "0.8.x", | |
| "grunt-contrib-jshint": "0.6.x", | |
| "grunt-contrib-stylus": "0.8.x", | |
| "grunt-contrib-uglify": "0.2.x", | |
| "grunt-contrib-watch": "0.5.x" | |
| }, | |
| "engine": "node >= 0.10" | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Being inspired by https://github.com/davemo/fem-grunt-workflow I converted Gruntfile.js into Gruntfile.coffee using http://priest.meteor.com/ for future uses.