createAssetServer

View Source

Summary

Create an asset server instance

Compiles TypeScript/JavaScript scripts and CSS styles on demand with optional source-based URL fingerprinting, caching, and configurable file mapping.

Signature

function createAssetServer(options: AssetServerOptions): AssetServer;

Example

let assetServer = createAssetServer({
  fileMap: {
    '/assets/app/*path': 'app/*path',
  },
  allow: ['app/**'],
})

route('/assets/*path', ({ request }) => assetServer.fetch(request))

Params

options

Server configuration

Returns

A AssetServer with fetch(), getHref(), and getPreloads() methods