Browser-sync: serve wasm files with correct mime type

Created on 1 Feb 2018  路  2Comments  路  Source: BrowserSync/browser-sync

Issue details

When serving .wasm (WebAsssembly) files the returned mime type is application/octet-stream. Browsers require this to be application/wasm to use these files.

Steps to reproduce/test case

  • Create or clone a webassemly project
  • Run browser-sync

Please specify which version of Browsersync, node and npm you're running

  • Browsersync [ 2.23.6 ]
  • Node [ v9.3.0 ]
  • Npm [ 5.6.0 ]

Affected platforms

  • [ ] linux
  • [ ] windows
  • [x] OS X
  • [ ] freebsd
  • [ ] solaris
  • [x] other _(most likely all the others too)_

Browsersync use-case

  • [ ] API
  • [ ] Gulp
  • [ ] Grunt
  • [x] CLI

If CLI, please paste the entire command below

browser-sync start --server

Most helpful comment

Create a bs-config.js file:

browser-sync init

... and add:

"callbacks": {
    ready: function(err, bs) {

        bs.utils.serveStatic.mime.define({ 'application/wasm': ['wasm'] });

        console.log("---> " + bs.utils.serveStatic.mime.lookup('.wasm'));
    }
},

Set all other options as required
(eg. server:true)

Start like this:

browser-sync start --config bs-config.js

Make sure you clean your browser cache.

All 2 comments

Traced the issue back to the send package. Here's the relevant PR pillarjs/send#154

Create a bs-config.js file:

browser-sync init

... and add:

"callbacks": {
    ready: function(err, bs) {

        bs.utils.serveStatic.mime.define({ 'application/wasm': ['wasm'] });

        console.log("---> " + bs.utils.serveStatic.mime.lookup('.wasm'));
    }
},

Set all other options as required
(eg. server:true)

Start like this:

browser-sync start --config bs-config.js

Make sure you clean your browser cache.

Was this page helpful?
0 / 5 - 0 ratings