From fadae5da6ba0261cade08164feeaad99b1de6b79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B3=E4=BB=B2=E6=98=87?= Date: Wed, 5 Dec 2018 20:25:23 +0700 Subject: [PATCH] fix(Server): mime type for wasm in contentBase directory (#1575) (#1580) --- 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