forked from remix-run/remix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
loaders.ts
41 lines (39 loc) · 943 Bytes
/
loaders.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import * as path from "path";
import type * as esbuild from "esbuild";
export const loaders: { [ext: string]: esbuild.Loader } = {
".aac": "file",
".css": "file",
".eot": "file",
".flac": "file",
".gif": "file",
".ico": "file",
".jpeg": "file",
".jpg": "file",
".js": "jsx",
".jsx": "jsx",
".json": "json",
// We preprocess md and mdx files using XDM and send through
// the JSX for esbuild to handle
".md": "jsx",
".mdx": "jsx",
".mp3": "file",
".mp4": "file",
".ogg": "file",
".otf": "file",
".png": "file",
".svg": "file",
".ts": "ts",
".tsx": "tsx",
".ttf": "file",
".wav": "file",
".webm": "file",
".webmanifest": "file",
".webp": "file",
".woff": "file",
".woff2": "file",
};
export function getLoaderForFile(file: string): esbuild.Loader {
let ext = path.extname(file);
if (ext in loaders) return loaders[ext];
throw new Error(`Cannot get loader for file ${file}`);
}