Skip to content

Instantly share code, notes, and snippets.

@amenzies
Forked from gbabiars/Grunt Proxy Server
Last active December 31, 2015 21:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amenzies/8047326 to your computer and use it in GitHub Desktop.
Save amenzies/8047326 to your computer and use it in GitHub Desktop.
I believe that there is an error in the original gist and that grunt.loadNpmTask should be grunt.loadNpmTasks
var proxySnippet = require('grunt-connect-proxy/lib/utils').proxyRequest;
module.exports = function(grunt) {
grunt.initConfig({
watch: {
all: {
files: ['Gruntfile.js']
}
},
connect: {
'static': {
options: {
hostname: 'localhost',
port: 8001
}
},
server: {
options: {
hostname: 'localhost',
port: 8000,
middleware: function(connect) {
return [proxySnippet];
}
},
proxies: [
{
context: '/svc',
host: 'myserviceshost',
port: 8080
},
{
context: '/api',
host: 'myapihost',
port: 9080
},
{
context: '/',
host: 'localhost',
port: 8001
}
]
},
fakeServer: {
options: {
hostname: 'localhost',
port: 8000,
middleware: function(connect) {
return [proxySnippet];
}
},
proxies: [
{
context: '/svc',
host: 'localhost',
port: 8080
},
{
context: '/api',
host: 'localhost',
port: 9080
},
{
context: '/',
host: 'localhost',
port: 8001
}
]
}
}
});
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-connect-proxy');
grunt.registerTask('server', ['connect:static', 'configureProxies:server', 'connect:server', 'watch']);
grunt.registerTask('fakeServer', ['connect:static', 'configureProxies:fakeServer', 'connect:fakeServer', 'watch']);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment