Created
January 26, 2014 02:16
-
-
Save hontas/8627196 to your computer and use it in GitHub Desktop.
Gruntfile setup with proxies, fakeEnd and Express server
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
/*global module:false*/ | |
var proxySnippet = require('grunt-connect-proxy/lib/utils').proxyRequest; | |
module.exports = function(grunt) { | |
grunt.initConfig({ | |
// Task configuration. | |
express: { | |
dev: { | |
options: { | |
script: 'dev/server.js' | |
} | |
}, | |
}, | |
connect: { | |
'static': { | |
options: { | |
hostname: 'localhost', | |
port: 3001 | |
} | |
}, | |
server: { | |
options: { | |
hostname: 'localhost', | |
port: 3000, | |
middleware: function(connect) { | |
return [proxySnippet]; | |
}, | |
open: true | |
}, | |
proxies: [ | |
{ | |
context: '/mem/services/rest', | |
host: 'localhost', | |
port: 8080 | |
}, | |
{ | |
context: '/', | |
host: 'localhost', | |
port: 3001 | |
} | |
] | |
} | |
}, | |
watch: { | |
express: { | |
files: 'dev/server.js', | |
tasks: ['express:dev'], | |
options: { | |
spawn: false | |
} | |
}, | |
gruntfile: { | |
files: 'Gruntfile.js', | |
tasks: [] | |
} | |
} | |
}); | |
// These plugins provide necessary tasks. | |
grunt.loadNpmTasks('grunt-express-server'); | |
grunt.loadNpmTasks('grunt-contrib-connect'); | |
grunt.loadNpmTasks('grunt-connect-proxy'); | |
grunt.loadNpmTasks('grunt-contrib-watch'); | |
// Default task. | |
grunt.registerTask('default', ['watch']); | |
grunt.registerTask('develop', ['connect:static', 'configureProxies:server', 'connect:server', 'watch']); | |
grunt.registerTask('fakeServer', ['express:dev', 'connect:static', 'configureProxies:server', 'connect:server', 'watch']); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment