From face777efb01595c27e932422ee8305f0ab05ee1 Mon Sep 17 00:00:00 2001 From: Gerard Rodes Date: Mon, 4 May 2020 12:03:33 +0200 Subject: [PATCH] adeded mimeTypes option --- README.md | 5 +++++ src/index.js | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/README.md b/README.md index c1a8e19..d0a5153 100644 --- a/README.md +++ b/README.md @@ -88,6 +88,11 @@ serve({ headers: { 'Access-Control-Allow-Origin': '*', foo: 'bar' + }, + + // set custom mime types, usage https://github.com/broofa/mime#mimedefinetypemap-force--false + mimeTypes: { + 'application/javascript': ['js_commonjs-proxy'] } }) ``` diff --git a/src/index.js b/src/index.js index e0d973c..83598bc 100644 --- a/src/index.js +++ b/src/index.js @@ -23,6 +23,10 @@ function serve (options = { contentBase: '' }) { options.openPage = options.openPage || '' mime.default_type = 'text/plain' + if (options.mimeTypes) { + mime.define(options.mimeTypes) + } + const requestListener = (request, response) => { // Remove querystring const unsafePath = decodeURI(request.url.split('?')[0])