Skip to content

Instantly share code, notes, and snippets.

@hontas
Created January 26, 2014 02:16
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hontas/8627196 to your computer and use it in GitHub Desktop.
Save hontas/8627196 to your computer and use it in GitHub Desktop.
Gruntfile setup with proxies, fakeEnd and Express server
/*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