Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set serveStaticOptions for server.routes as well #1741

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/browser-sync/lib/server/static-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ module.exports = function createServer(bs) {
id:
"Browsersync Server Routes Middleware - " +
_routes++,
handle: serveStatic(resolve(root))
handle: serveStatic(resolve(root), serveStaticOptions)
};
})
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,40 @@ describe("E2E server test with serve static options", function() {
});
});
});
it("also sets the index of serve-static to routes", function(done) {
browserSync.reset();

var config = {
server: {
baseDir: "test/fixtures",
serveStaticOptions: {
index: "inputs.html"
},
routes: {
"/subdir": "test/fixtures"
}
},
logLevel: "silent",
open: false
};

browserSync.create().init(config, function(err, bs) {
request(bs.server)
.get("/subdir/")
.expect(200)
.end(function(err, res) {
assert.deepEqual(
require("fs").readFileSync(
"test/fixtures/inputs.html",
"utf-8"
),
res.text
);
bs.cleanup();
done();
});
});
});
it("sets uses the default for serve static index", function(done) {
browserSync.reset();

Expand Down