Remix
Remix
remix/assets · FunctionView Source

createAssetServer

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({
  basePath: "/assets",
  fileMap: {
    "/app/*path": "app/*path",
  },
  allow: ["app/**"],
});

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

Parameters

options

Server configuration

Returns

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