Created
August 18, 2014 14:34
-
-
Save anderson-mota/a55bbe4c61acad98ab7e to your computer and use it in GitHub Desktop.
Gruntfile com algumas tarefas: Compass, Ugrify, Connect, Livereload, Bower Install.
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
/** | |
* Created by Mota on 10/08/2014. | |
*/ | |
module.exports = function(grunt) { | |
var mountFolder = function (connect, dir) { | |
return connect.static(require('path').resolve(dir)); | |
}; | |
grunt.initConfig({ | |
pkg: grunt.file.readJSON('package.json'), | |
compass: { | |
dist: { | |
options: { | |
config: 'config.rb' | |
} | |
} | |
}, | |
concat: { | |
options: { | |
separator: ';' | |
}, | |
dist: { | |
src: ['app/js/**/*.js'], | |
dest: 'dist/<%= pkg.name %>.js' | |
} | |
}, | |
uglify: { | |
options: { | |
banner: '/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %> */\n' | |
}, | |
dist: { | |
files: { | |
'dist/<%= pkg.name %>.min.js': ['<%= concat.dist.dest %>'] | |
} | |
} | |
}, | |
jshint: { | |
files: ['Gruntfile.js', 'app/js/**/*.js', 'test/**/*.js'], | |
options: { | |
// options here to override JSHint defaults | |
globals: { | |
jQuery: true, | |
console: true, | |
module: true, | |
document: true | |
} | |
} | |
}, | |
bower: { | |
install: { | |
options: { | |
targetDir: "./app/components", | |
layout: "byComponent" | |
} | |
} | |
}, | |
connect: { | |
server: { | |
options: { | |
port: 8000, | |
base: 'app', | |
hostname: 'localhost', | |
livereload: true, | |
open: true, | |
middleware: function (connect) { | |
return [ | |
require('connect-livereload')(), | |
mountFolder(connect, '.tmp'), | |
mountFolder(connect, 'app') | |
]; | |
} | |
} | |
} | |
}, | |
open: { | |
all: { | |
path: 'http://localhost:<%= connect.server.options.port %>' | |
} | |
}, | |
watch: { | |
dev: { | |
files: ['./app/**/*'], | |
tasks:[], | |
options: { | |
livereload: true | |
} | |
}, | |
style: { | |
files: ['./app/sass/**/*.scss'], | |
tasks: ['compass'] | |
} | |
} | |
}); | |
grunt.loadNpmTasks('grunt-contrib-uglify'); | |
grunt.loadNpmTasks('grunt-contrib-jshint'); | |
grunt.loadNpmTasks('grunt-contrib-watch'); | |
grunt.loadNpmTasks('grunt-contrib-concat'); | |
grunt.loadNpmTasks('grunt-contrib-compass'); | |
grunt.loadNpmTasks('grunt-contrib-connect'); | |
grunt.loadNpmTasks('grunt-open'); | |
grunt.loadNpmTasks('grunt-bower-task'); | |
grunt.registerTask('default', ['jshint', 'concat', 'uglify', 'compass']); | |
grunt.registerTask('server', ['connect:server', 'watch:dev']); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment