From 116ed33393de59857e70ee1836d4a112e7cb70e0 Mon Sep 17 00:00:00 2001 From: David Date: Mon, 17 Aug 2015 16:10:11 +0200 Subject: [PATCH 1/4] Allow port change and configuration in conf.js --- app/templates/gulp/_conf.js | 5 +++++ app/templates/gulp/_server.js | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/templates/gulp/_conf.js b/app/templates/gulp/_conf.js index a0253a6c..f9aae1d7 100644 --- a/app/templates/gulp/_conf.js +++ b/app/templates/gulp/_conf.js @@ -41,3 +41,8 @@ exports.errorHandler = function(title) { this.emit('end'); }; }; + +/** + * Port used by browsersync + */ +exports.port = 4000; diff --git a/app/templates/gulp/_server.js b/app/templates/gulp/_server.js index be24f81e..7d937780 100644 --- a/app/templates/gulp/_server.js +++ b/app/templates/gulp/_server.js @@ -27,7 +27,8 @@ function browserSyncInit(baseDir, browser) { var server = { baseDir: baseDir, - routes: routes + routes: routes, + port: conf.port }; /* From 230096fd5f3be98c611f487baba0f4f2187881e7 Mon Sep 17 00:00:00 2001 From: David Date: Mon, 17 Aug 2015 16:25:58 +0200 Subject: [PATCH 2/4] Reverting to port 3000 --- app/templates/gulp/_conf.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/templates/gulp/_conf.js b/app/templates/gulp/_conf.js index f9aae1d7..027bf07e 100644 --- a/app/templates/gulp/_conf.js +++ b/app/templates/gulp/_conf.js @@ -45,4 +45,4 @@ exports.errorHandler = function(title) { /** * Port used by browsersync */ -exports.port = 4000; +exports.port = 3000; From 4752e1f24b4ef24496b41f668a690573114d8b58 Mon Sep 17 00:00:00 2001 From: David Date: Tue, 18 Aug 2015 12:02:18 +0200 Subject: [PATCH 3/4] Remove implem and document how to configure port --- app/templates/gulp/_conf.js | 5 ----- app/templates/gulp/_server.js | 3 +-- docs/how-it-works.md | 10 ++++++++++ 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/app/templates/gulp/_conf.js b/app/templates/gulp/_conf.js index 027bf07e..a0253a6c 100644 --- a/app/templates/gulp/_conf.js +++ b/app/templates/gulp/_conf.js @@ -41,8 +41,3 @@ exports.errorHandler = function(title) { this.emit('end'); }; }; - -/** - * Port used by browsersync - */ -exports.port = 3000; diff --git a/app/templates/gulp/_server.js b/app/templates/gulp/_server.js index 7d937780..be24f81e 100644 --- a/app/templates/gulp/_server.js +++ b/app/templates/gulp/_server.js @@ -27,8 +27,7 @@ function browserSyncInit(baseDir, browser) { var server = { baseDir: baseDir, - routes: routes, - port: conf.port + routes: routes }; /* diff --git a/docs/how-it-works.md b/docs/how-it-works.md index 5cc07d80..75cf3d7f 100644 --- a/docs/how-it-works.md +++ b/docs/how-it-works.md @@ -155,6 +155,16 @@ The base directories for Browser Sync are `.tmp/serve` and `src` with a priority As the `bower_components` folder is not located in any of the base paths, a special routes is added for this folder to be addressed by `/bower_components`. +The default Browser Sync port is `3000`, if you ever need to change it, head over to the [gulp/server.js](https://github.com/Swiip/generator-gulp-angular/blob/master/app/templates/gulp/_server.js#L30) file and add the `port` attribute to the *server* variable. +Example below : +```javascript +var server = { + baseDir: baseDir, + routes: routes, + port: 4000 + }; +``` + Last configuration, the `browser` option is used to open the default browser to the root page. ### Proxy From c664755b151281a7fcb208b1c78045ecacfd05a2 Mon Sep 17 00:00:00 2001 From: David Date: Tue, 18 Aug 2015 12:32:33 +0200 Subject: [PATCH 4/4] DOC - Link BrowserSync list of options --- docs/how-it-works.md | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/docs/how-it-works.md b/docs/how-it-works.md index 75cf3d7f..53a8740c 100644 --- a/docs/how-it-works.md +++ b/docs/how-it-works.md @@ -155,18 +155,21 @@ The base directories for Browser Sync are `.tmp/serve` and `src` with a priority As the `bower_components` folder is not located in any of the base paths, a special routes is added for this folder to be addressed by `/bower_components`. -The default Browser Sync port is `3000`, if you ever need to change it, head over to the [gulp/server.js](https://github.com/Swiip/generator-gulp-angular/blob/master/app/templates/gulp/_server.js#L30) file and add the `port` attribute to the *server* variable. +The default Browser Sync port is `3000`, if you ever need to change it, head over to the [gulp/server.js](https://github.com/Swiip/generator-gulp-angular/blob/master/app/templates/gulp/_server.js#L42) file and add the `port` attribute to the *server* variable. Example below : ```javascript -var server = { - baseDir: baseDir, - routes: routes, - port: 4000 - }; +browserSync.instance = browserSync.init({ + startPath: '/', + server: server, + browser: browser, + port: 4000 // Add this line to change the default port + }); ``` Last configuration, the `browser` option is used to open the default browser to the root page. +Head over to [Browser Sync list of options](http://www.browsersync.io/docs/options/) for the full list of available configurations for BrowserSync. + ### Proxy Browser Sync is powered by an express server. The API allows us to inject any Express middleware. Behind comments, an example of use of [http-proxy-middleware](https://github.com/chimurai/http-proxy-middleware) is prepared.