From 3b39be7bf7bf1268dffb4d04050a64411e6062c9 Mon Sep 17 00:00:00 2001 From: Chung-Sheng Wu Date: Tue, 27 Nov 2018 21:15:21 +0800 Subject: [PATCH] fix(Server): Workaround for .wasm file mime type (#1575) --- lib/Server.js | 4 ++++ test/ContentBase.test.js | 14 ++++++++++++++ test/fixtures/contentbase-config/public/foo.wasm | 0 3 files changed, 18 insertions(+) create mode 100644 test/fixtures/contentbase-config/public/foo.wasm diff --git a/lib/Server.js b/lib/Server.js index df60ccff74..0030fa560d 100644 --- a/lib/Server.js +++ b/lib/Server.js @@ -132,6 +132,10 @@ function Server (compiler, options = {}, _log) { // eslint-disable-next-line const app = this.app = new express(); + // ref: https://github.com/webpack/webpack-dev-server/issues/1575 + // remove this when send@^0.16.3 + express.static.mime.types.wasm = 'application/wasm'; + app.all('*', (req, res, next) => { if (this.checkHost(req.headers)) { return next(); diff --git a/test/ContentBase.test.js b/test/ContentBase.test.js index c2d105f50e..bcd98a7acd 100644 --- a/test/ContentBase.test.js +++ b/test/ContentBase.test.js @@ -121,4 +121,18 @@ describe('ContentBase', () => { .expect(404, done); }); }); + + describe('Content type', () => { + before((done) => { + server = helper.start(config, { + contentBase: [contentBasePublic] + }, done); + req = request(server.app); + }); + + it('Request foo.wasm', (done) => { + req.get('/foo.wasm') + .expect('Content-Type', 'application/wasm', done); + }); + }); }); diff --git a/test/fixtures/contentbase-config/public/foo.wasm b/test/fixtures/contentbase-config/public/foo.wasm new file mode 100644 index 0000000000..e69de29bb2