Last active
August 29, 2015 14:19
-
-
Save ikouchiha47/2f009027f86bc61fca20 to your computer and use it in GitHub Desktop.
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
'use strict'; | |
module.exports = function (grunt) { | |
grunt.initConfig({ | |
jshint: { | |
src: ['app/**/*.js'], | |
options: { | |
eqeqeq: true, | |
curly: true, | |
laxcomma: true | |
} | |
}, | |
connect: { | |
options: { | |
port: 9000, | |
hostname: 'localhost', | |
livereload: 35729, | |
base: './' | |
}, | |
proxies: [ | |
{ | |
context: '/api/v1', | |
host: 'localhost', | |
port: 3000 | |
} | |
], | |
livereload: { | |
options: { | |
middleware: function(connect, options) { | |
if (!Array.isArray(options.base)) { | |
options.base = [options.base]; | |
} | |
// Setup the proxy | |
var middlewares = []; | |
// Serve static files. | |
options.base.forEach(function(base) { | |
middlewares.push(connect.static(base)); | |
}); | |
// Make directory browse-able. | |
var directory = options.directory || options.base[options.base.length - 1]; | |
middlewares.push(connect.directory(directory)); | |
return middlewares; | |
} | |
} | |
} | |
}, | |
watch: { | |
options: { | |
livereload: '<%= connect.options.livereload %>', | |
dateFormat: function(time) { | |
grunt.log.writeln('The watch finished in ' + time + 'ms at' + (new Date()).toString()); | |
grunt.log.writeln('Waiting for more changes...'); | |
} | |
}, | |
files: ['Gruntfile.js', 'app/**/*.js', 'app/**/*.css', 'bower_components/**/*.css'], | |
tasks: ['jshint'] | |
} | |
}); | |
grunt.registerTask('default', ['jshint']); | |
grunt.registerTask('serve', ['default', 'configureProxies', 'connect:livereload', 'watch']); | |
grunt.loadNpmTasks('grunt-contrib-jshint'); | |
grunt.loadNpmTasks('grunt-contrib-watch'); | |
grunt.loadNpmTasks('grunt-connect-proxy'); | |
grunt.loadNpmTasks('grunt-contrib-connect'); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment