Created
April 4, 2015 23:05
-
-
Save anonymous/3894d93d83a5a0b61fd0 to your computer and use it in GitHub Desktop.
Grunt-Connect-Proxy Gruntfile.js
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
// The actual grunt server settings | |
connect: { | |
options: { | |
port: 9000, | |
// Change this to '0.0.0.0' to access the server from outside. | |
hostname: 'localhost', | |
livereload: 35729 | |
}, | |
proxies: [ | |
{ | |
context: '/api', | |
host: 'localhost', | |
port: 3000 | |
} | |
], | |
livereload: { | |
options: { | |
open: true, | |
middleware: function (connect) { | |
return [ | |
connect.static('.tmp'), | |
connect().use( | |
'/bower_components', | |
connect.static('./bower_components') | |
), | |
connect().use( | |
'/app/styles', | |
connect.static('./app/styles') | |
), | |
connect.static(appConfig.app) | |
]; | |
} | |
} | |
}, | |
test: { | |
options: { | |
port: 9001, | |
middleware: function (connect) { | |
return [ | |
connect.static('.tmp'), | |
connect.static('test'), | |
connect().use( | |
'/bower_components', | |
connect.static('./bower_components') | |
), | |
connect.static(appConfig.app) | |
]; | |
} | |
} | |
}, | |
dist: { | |
options: { | |
open: true, | |
base: '<%= yeoman.dist %>' | |
} | |
} | |
}, |
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
module.exports = function (grunt) { | |
//load grunt-connect-proxy | |
grunt.loadNpmTasks('grunt-connect-proxy'); | |
// Load grunt tasks automatically | |
require('load-grunt-tasks')(grunt); | |
// Time how long tasks take. Can help when optimizing build times | |
require('time-grunt')(grunt); | |
// Configurable paths for the application | |
var appConfig = { | |
app: require('./bower.json').appPath || 'app', | |
dist: 'dist' | |
}; |
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
grunt.registerTask('serve', 'Compile then start a connect web server', function (target) { | |
if (target === 'dist') { | |
return grunt.task.run(['build', 'connect:dist:keepalive']); | |
} | |
grunt.task.run([ | |
'clean:server', | |
'wiredep', | |
'concurrent:server', | |
'autoprefixer:server', | |
'configureProxies', | |
'connect:livereload', | |
'watch' | |
]); | |
}); |
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
Remote Address:127.0.0.1:9000 | |
Request URL:http://localhost:9000/articles | |
Request Method:GET | |
Status Code:404 Not Found |
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
Running "configureProxies" task | |
Proxy created for: /api to localhost:3000 | |
Running "connect:livereload" (connect) task | |
Verifying property connect.livereload exists in config...OK | |
File: [no files] | |
Options: protocol="http", port=9000, hostname="localhost", base=".", directory=null, keepalive=false, debug=false, livereload=35729, open, useAvailablePort=false, onCreateServer=null, middleware=undefined | |
Started connect web server on http://localhost:9000 | |
Running "watch" task | |
Waiting... | |
Verifying property watch exists in config...OK | |
Verifying property watch.bower.files exists in config...OK | |
Verifying property watch.js.files exists in config...OK | |
Verifying property watch.jsTest.files exists in config...OK | |
Verifying property watch.styles.files exists in config...OK | |
Verifying property watch.gruntfile.files exists in config...OK | |
Verifying property watch.livereload.files exists in config...OK | |
Live reload server started on port: 35729 | |
Watching bower.json for changes. | |
Watching .tmp for changes. | |
Watching app for changes. | |
Watching bower_components for changes. | |
Watching node_modules for changes. | |
Watching test for changes. | |
Watching app/scripts/app.js for changes. | |
Watching app/scripts/controllers for changes. | |
Watching app/scripts/controllers/main.js for changes. | |
Watching test/spec/controllers/main.js for changes. | |
Watching app/styles/main.css for changes. | |
Watching Gruntfile.js for changes. | |
Watching .tmp for changes. | |
Watching app for changes. | |
Watching bower_components for changes. | |
Watching node_modules for changes. | |
Watching test for changes. | |
Watching app/404.html for changes. | |
Watching app/images for changes. | |
Watching app/scripts for changes. | |
Watching app/styles for changes. | |
Watching app/views for changes. | |
Watching app/index.html for changes. | |
Watching app/views/main.html for changes. | |
Watching .tmp/styles/main.css for changes. | |
Watching app/images/yeoman.png for changes. | |
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
Rails.application.routes.draw do | |
namespace :api, defaults: {format: "json"} do | |
resources :articles | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment