Allow server access from outside

This commit is contained in:
Andrew Abogado 2015-01-28 09:43:10 +08:00
parent 2a49046ff0
commit 5e035395b5

View file

@ -8,7 +8,7 @@
// If you want to recursively match all subfolders, use: // If you want to recursively match all subfolders, use:
// 'test/spec/**/*.js' // 'test/spec/**/*.js'
module.exports = function (grunt) { module.exports = function(grunt) {
// Time how long tasks take. Can help when optimizing build times // Time how long tasks take. Can help when optimizing build times
require('time-grunt')(grunt); require('time-grunt')(grunt);
@ -75,14 +75,15 @@ module.exports = function (grunt) {
open: true, open: true,
livereload: 35729, livereload: 35729,
// Change this to '0.0.0.0' to access the server from outside // Change this to '0.0.0.0' to access the server from outside
hostname: 'localhost' hostname: '0.0.0.0'
}, },
livereload: { livereload: {
options: { options: {
middleware: function(connect) { middleware: function(connect) {
return [ return [
connect.static('.tmp'), connect.static('.tmp'),
connect().use('/bower_components', connect.static('./bower_components')), connect().use('/bower_components', connect.static(
'./bower_components')),
connect.static(config.app) connect.static(config.app)
]; ];
} }
@ -96,7 +97,8 @@ module.exports = function (grunt) {
return [ return [
connect.static('.tmp'), connect.static('.tmp'),
connect.static('test'), connect.static('test'),
connect().use('/bower_components', connect.static('./bower_components')), connect().use('/bower_components', connect.static(
'./bower_components')),
connect.static(config.app) connect.static(config.app)
]; ];
} }
@ -144,7 +146,9 @@ module.exports = function (grunt) {
all: { all: {
options: { options: {
run: true, run: true,
urls: ['http://<%= connect.test.options.hostname %>:<%= connect.test.options.port %>/index.html'] urls: [
'http://<%= connect.test.options.hostname %>:<%= connect.test.options.port %>/index.html'
]
} }
} }
}, },
@ -195,7 +199,9 @@ module.exports = function (grunt) {
app: { app: {
ignorePath: /^\/|\.\.\//, ignorePath: /^\/|\.\.\//,
src: ['<%= config.app %>/index.html'], src: ['<%= config.app %>/index.html'],
exclude: ['bower_components/bootstrap-sass-official/assets/javascripts/bootstrap.js'] exclude: [
'bower_components/bootstrap-sass-official/assets/javascripts/bootstrap.js'
]
}, },
sass: { sass: {
src: ['<%= config.app %>/styles/{,*/}*.{scss,sass}'], src: ['<%= config.app %>/styles/{,*/}*.{scss,sass}'],
@ -365,7 +371,9 @@ module.exports = function (grunt) {
}); });
grunt.registerTask('serve', 'start the server and preview your app, --allow-remote for remote access', function (target) { grunt.registerTask('serve',
'start the server and preview your app, --allow-remote for remote access',
function(target) {
if (grunt.option('allow-remote')) { if (grunt.option('allow-remote')) {
grunt.config.set('connect.options.hostname', '0.0.0.0'); grunt.config.set('connect.options.hostname', '0.0.0.0');
} }
@ -383,12 +391,14 @@ module.exports = function (grunt) {
]); ]);
}); });
grunt.registerTask('server', function (target) { grunt.registerTask('server', function(target) {
grunt.log.warn('The `server` task has been deprecated. Use `grunt serve` to start a server.'); grunt.log.warn(
'The `server` task has been deprecated. Use `grunt serve` to start a server.'
);
grunt.task.run([target ? ('serve:' + target) : 'serve']); grunt.task.run([target ? ('serve:' + target) : 'serve']);
}); });
grunt.registerTask('test', function (target) { grunt.registerTask('test', function(target) {
if (target !== 'watch') { if (target !== 'watch') {
grunt.task.run([ grunt.task.run([
'clean:server', 'clean:server',