-
-
Save ericsonluciano/1d9b4f267203271d5793 to your computer and use it in GitHub Desktop.
my gruntfile.js
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
/* | |
* Mintsflow | |
* http://mintsflow.ericsonluciano.me | |
* Created by Ericson Luciano | |
* Gruntfile.js | |
*/ | |
'use strict'; | |
var livereload_port = 35729; | |
var lrSnippet = require('connect-livereload')({ | |
port: livereload_port | |
}); | |
var folderMount = function folderMount(connect, point) { | |
return connect.static(require('path').resolve(point)); | |
}; | |
module.exports = function(grunt) { | |
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNPMTasks); | |
/* | |
* Project Grunt Configurations | |
*/ | |
grunt.initConfig({ | |
pkg: grunt.file.readJSON('package.json'), | |
/* | |
* Project Informations | |
*/ | |
project: { | |
source: 'source', | |
main: 'projects', | |
assets: '<%= project.main %>/assets', | |
css: [ | |
'<%= project.source %>/styles/main.scss' | |
], | |
js: [ | |
'<%= project.source %>/javascripts/*.js' | |
] | |
}, | |
/* | |
* Project Banners for CSS and JS | |
*/ | |
tag: { | |
banner: '/*\n' + | |
' * <%= pkg.name %>\n' + | |
' * <%= pkg.version %>\n' + | |
' * <%= pkg.title %>\n' + | |
' * <%= pkg.url %>\n' + | |
' * Github Repo <%= pkg.repository.url %>\n' + | |
' * created by <%= pkg.author %> - <%= pkg.url %>\n' + | |
' * <%= pkg.license %> licensed\n' + | |
' */\n' | |
}, | |
/* | |
* Grunt Contrib Connect | |
* http://github.com/gruntjs/grunt-contrib-connect | |
* http://www.npmjs.org/package/grunt-contrib-connect | |
* | |
*/ | |
connect: { | |
options: { | |
port: 9000, | |
hostname: 'localhost' | |
}, | |
livereload: { | |
options: { | |
middleware: function (connect) { | |
return [lrSnippet, folderMount(connect, 'projects')]; | |
} | |
} | |
} | |
}, | |
/* | |
* Grunt Contrib Clear | |
* https://github.com/gruntjs/grunt-contrib-clean | |
* http://www.npmjs.org/package/ggrunt-contrib-clean | |
* | |
*/ | |
clean: { | |
dist: [ | |
'<%= project.assets %>/css/styles.unprefixed.css', | |
'<%= project.assets %>/css/styles.prefixed.css' | |
] | |
}, | |
/* | |
* Grunt Contrib Jshint | |
* https://github.com/gruntjs/grunt-contrib-jshint | |
* http://www.npmjs.org/package/ggrunt-contrib-jshint | |
* | |
*/ | |
jshint: { | |
files: [ | |
'source/javascripts/*.js', | |
'Gruntfile.js' | |
], | |
options: { | |
jhintrc: '.jshintrc' | |
} | |
}, | |
/* | |
* Grunt Contrib SASS | |
* https://github.com/gruntjs/grunt-contrib-sass | |
* http://www.npmjs.org/package/ggrunt-contrib-sass | |
* | |
*/ | |
sass: { | |
dev: { | |
options: { | |
style: 'expanded', | |
banner: '<%= tag.banner %>' | |
}, | |
files: { | |
'<%= project.assets %>/css/styles.unprefixed.css' : '<%= project.css %>' | |
} | |
}, | |
dist: { | |
options: { | |
style: 'expanded' | |
}, | |
files: { | |
'<%= project.assets %>/css/styles.unprefixed.css' : '<%= project.css %>' | |
} | |
} | |
}, | |
/* | |
* Grunt Contrib CSS Minification | |
* https://github.com/gruntjs/grunt-contrib-cssmin | |
* http://www.npmjs.org/package/ggrunt-contrib-cssmin | |
* | |
*/ | |
cssmin: { | |
dev: { | |
options: { | |
banner: '<%= tag.banner %>' | |
}, | |
files: { | |
'<%= project.assets %>/css/styles.min.css': [ | |
'<%= project.source %>/components/normalize-css/normalize.css', | |
'<%= project.assets %>/css/styles.unprefixed.css' | |
] | |
} | |
}, | |
dist: { | |
options: { | |
banner: '<%= tag.banner %>' | |
}, | |
files: { | |
'<%= project.assets %>/css/styles.min.css': [ | |
'<%= project.source %>/components/normalize-css/normalize.css', | |
'<%= project.assets %>/css/styles.prefixed.css' | |
] | |
} | |
} | |
}, | |
/* | |
* Grunt Contrib Concatinate Javascript | |
* https://github.com/gruntjs/grunt-contrib-concat | |
* http://www.npmjs.org/package/ggrunt-contrib-concat | |
* | |
*/ | |
concat: { | |
options: { | |
stripBanners: true, | |
nonull: true, | |
banner: '<%= tag.banner %>' | |
}, | |
dev: { | |
files: { | |
'<%= project.assets %>/js/scripts.min.js' : '<%= project.js %>' | |
} | |
} | |
}, | |
/* | |
* Grunt Contrib Uglify | |
* https://github.com/gruntjs/grunt-contrib-uglify | |
* http://www.npmjs.org/package/ggrunt-contrib-uglify | |
* | |
*/ | |
uglify: { | |
options: { | |
banner: '<%= tag.banner %>' | |
}, | |
dist: { | |
files: { | |
'<%= project.assets %>/js/scripts.min.js' : '<%= project.js %>' | |
} | |
} | |
}, | |
/* | |
* Grunt Autoprefixer | |
* https://github.com/nDmitry/grunt-autoprefixer | |
* http://www.npmjs.org/package/ggrunt-autoprefixer | |
* | |
*/ | |
autoprefixer: { | |
options: { | |
browser: [ | |
'last 2 version', | |
'ie 9', | |
'safari 6', | |
'ios 7', | |
'android 4', | |
'opera 12' | |
] | |
}, | |
dev: { | |
files: { | |
'<%= project.assets %>/css/styles.min.css': ['<%= project.assets %>/css/styles.unprefixed.css'] | |
} | |
}, | |
dist: { | |
files: { | |
'<%= project.assets %>/css/styles.prefixed.css': ['<%= project.assets %>/css/styles.prefixed.css'] | |
} | |
} | |
}, | |
/* | |
* Bower Components | |
* https://github.com/yatskevich/grunt-bower | |
* http://www.npmjs.org/package/grunt-bower | |
* | |
*/ | |
bower: { | |
dev: { | |
dest: '<%= project.assets %>/components/' | |
}, | |
dist: { | |
dest: '<%= project.assets %>/components/' | |
} | |
}, | |
/* | |
* Grunt Open | |
* https://github.com/jsoverson/grunt-open | |
* http://www.npmjs.org/package/grunt-open | |
* | |
*/ | |
open: { | |
dev: { | |
path:'http://localhost:<%= connect.options.port %>', | |
app: ['Google Chrome'] | |
} | |
}, | |
/* | |
* Grunt Notify | |
* https://github.com/dylang/grunt-notify | |
* http://www.npmjs.org/package/grunt-notify | |
* | |
*/ | |
notify_hooks: { | |
options: { | |
enabled: true, | |
max_jshint_notifications: 5, | |
title: '<%= pkg.name %>' | |
} | |
}, | |
notify: { | |
task_name: { | |
options: { | |
title: '<%= pkg.name %>', | |
message: 'Currently doing the task' | |
} | |
}, | |
watch: { | |
options: { | |
title: '<%= pkg.name %> Task Complete', | |
message: 'Sass, Uglify, Concat, Imagemin finished running' | |
} | |
}, | |
server: { | |
options: { | |
title: '<%= pkg.name %> Server', | |
message: 'Server is ready!' | |
} | |
} | |
}, | |
/* | |
* Grunt Contrib Watch | |
* https://github.com/gruntjs/grunt-contrib-watch | |
* http://www.npmjs.org/package/grunt-contrib-watch | |
* | |
*/ | |
watch:{ | |
concat: { | |
files: '<%= project.source %>/javascripts/{,*/}*.js', | |
tasks: ['concat:dev', jshint] | |
}, | |
sass: { | |
files: '<%= project.source %>/styles/{,*/}*.{scss,sass}', | |
tasks: ['sass:dev', 'cssmin:dev', 'autoprefixer:dev'] | |
}, | |
livereload: { | |
options: { | |
livereload: livereload_port | |
}, | |
files: [ | |
'<%= project.main %>/{,*/}*.html', | |
'<%= project.assets %>/css/*.css', | |
'<%= project.assets %>/js/{,*/}*.js', | |
'<%= project.assets %>/img/*.{png,jpg,jpeg,gif,webp,svg}' | |
] | |
} | |
} | |
}); | |
grunt.registerTask('default', [ | |
'sass:dev', | |
'concat:dev', | |
'autoprefixer:dev', | |
'bower:dev', | |
'cssmin:dev', | |
'jshint', | |
'connect:livereload', | |
'open:dev', | |
'notify_hooks', | |
'notify:server', | |
'watch' | |
]); | |
grunt.registerTask('build', [ | |
'sass:dist', | |
'bower:dist', | |
'autoprefixer:dist', | |
'cssmin:dist', | |
'clean:dist', | |
'jshint', | |
'uglify' | |
]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment