Skip to content

Commit cc2f4d9

Browse files
committed
[wip] More SS options
1 parent c1bfc5c commit cc2f4d9

4 files changed

Lines changed: 37 additions & 24 deletions

File tree

lib/async-tasks.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,6 @@ module.exports = [
4545
step: "Starting the Server",
4646
fn: async.startServer
4747
},
48-
{
49-
step: "Adding serve static middlewares",
50-
fn: async.addServeStaticMiddleware
51-
},
5248
{
5349
step: "Starting the HTTPS Tunnel",
5450
fn: async.startTunnel

lib/async.js

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -246,18 +246,6 @@ module.exports = {
246246
}
247247
});
248248
},
249-
/**
250-
* @param bs
251-
* @param done
252-
*/
253-
addServeStaticMiddleware: function (bs, done) {
254-
bs.options
255-
.get("serveStatic")
256-
.forEach(function (dir) {
257-
bs.addMiddleware("*", utils.serveStatic(dir));
258-
});
259-
done();
260-
},
261249
/**
262250
* @param {BrowserSync} bs
263251
* @param {Function} done

lib/browser-sync.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@ BrowserSync.prototype.doFileReload = function (data) {
655655

656656
/**
657657
* If the current item will cause the browser
658-
* to reload, fire the correct
658+
* to reload, fire the correct
659659
*/
660660
if (willReload) {
661661
bs.io.sockets.emit("browser:reload");

lib/server/utils.js

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
"use strict";
22

3-
var fs = require("fs");
4-
var filePath = require("path");
5-
var connect = require("connect");
6-
var http = require("http");
7-
var https = require("https");
8-
var Map = require("immutable").Map;
9-
var snippet = require("./../snippet").utils;
3+
var fs = require("fs");
4+
var filePath = require("path");
5+
var connect = require("connect");
6+
var Immutable = require("immutable");
7+
var http = require("http");
8+
var https = require("https");
9+
var Map = require("immutable").Map;
10+
var snippet = require("./../snippet").utils;
11+
var _ = require("./../../lodash.custom");
12+
var serveStatic = require("serve-static");
1013

1114
var utils = {
1215
/**
@@ -79,6 +82,32 @@ var utils = {
7982
})
8083
}
8184

85+
if (options.get('serveStatic')) {
86+
options
87+
.get("serveStatic")
88+
.forEach(function (dir, i) {
89+
if (Immutable.Map.isMap(dir)) {
90+
var ssOptions = (function () {
91+
if (dir.get('options')) {
92+
return dir.get('options').toJS();
93+
}
94+
return {}
95+
})();
96+
defaultMiddlewares.push({
97+
id: "Serve static " + i,
98+
route: dir.get("route"),
99+
handle: serveStatic(dir.get("dir"), ssOptions)
100+
});
101+
} else if (_.isString(dir)) {
102+
defaultMiddlewares.push({
103+
id: "Serve static " + i,
104+
route: "",
105+
handle: serveStatic(dir, options.get('serveStaticOptions').toJS())
106+
});
107+
}
108+
});
109+
}
110+
82111
/**
83112
* Add the proxy Middleware to the end of the stack
84113
*/

0 commit comments

Comments
 (0)