Skip to content

Instantly share code, notes, and snippets.

@danjesus
Forked from anderson-mota/Gruntfile.js
Created August 18, 2014 14:43
Show Gist options
  • Save danjesus/6ee12a143860098cbc71 to your computer and use it in GitHub Desktop.
Save danjesus/6ee12a143860098cbc71 to your computer and use it in GitHub Desktop.
/**
* 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