Skip to content

Commit

Permalink
feat: add handler for map files
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Sep 30, 2018
1 parent 9faab1c commit 6709714
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,12 @@ Theese are default handles. See [options](#options) section to see how to custom

Handler | Extensions | Mime type | Placeholder
---------|---------------------------------------------------|--------------------------|-------------------
js | `js` | `application/javascript` | `/* script not found */`
json | `json` | `application/json` | `{}`
html | `html`, `htm` | `text/html` | `<!-- page not found -->`
css | `css` | `text/css` | `/* style not found */`
html | `html`, `htm` | `text/html` | `<!-- page not found -->`
image | `png`, `jpg`, `jpeg`, `gif`, `svg`, `webp`, `bmp` | `image/gif` | transparent 1x1 image
js | `js` | `application/javascript` | `/* script not found */`
json | `json` | `application/json` | `{}`
map | `map` | `application/json` | `{"version": "3", "sources": [], "mappings": "" }`

## Options

Expand Down
29 changes: 20 additions & 9 deletions src/defaults.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,47 @@
const EMPTY_GIF = Buffer.from('R0lGODlhAQABAIABAP///wAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==', 'base64')

module.exports = {
statusCode: 404,

skipUnknown: false,

handler: {
'.js': 'js',
'.json': 'json',
// css
'.css': 'css',
// html
'.html': 'html',
'.htm': 'html',
// image
'.png': 'image',
'.jpg': 'image',
'.jpeg': 'image',
'.gif': 'image',
'.svg': 'image',
'.webp': 'image',
'.bmp': 'image'
'.bmp': 'image',
// js
'.js': 'js',
// json
'.json': 'json',
// map
'.map': 'map'
},

placeholder: {
css: '/* style not found */',
html: '<!-- page not found -->',
image: EMPTY_GIF,
js: '/* script not found */',
json: '{}',
html: '<!-- page not found -->',
css: '/* style not found */',
image: Buffer.from('R0lGODlhAQABAIABAP///wAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==', 'base64')
map: '{"version": "3", "sources": [], "mappings": "" }'
},

mime: {
css: 'text/css',
html: 'text/html',
js: 'application/javascript',
json: 'application/json',
html: 'text/html',
css: 'text/css',
image: 'image/gif'
image: 'image/gif',
map: 'application/json'
}
}

0 comments on commit 6709714

Please sign in to comment.