mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-05 16:23:36 +00:00
Handle static assets as files in esbuild
This commit is contained in:
2 files changed
+10
-4
No files matched your search
@@ -1,3 +1,4 @@
|
||||
import { extname } from "path-browserify";
|
||||
import type { Loader, Plugin } from "esbuild-wasm";
|
||||
|
||||
interface PackageLock {
|
||||
@@ -334,8 +335,9 @@ export function esmPlugin(packageLock: PackageLock, target?: string): Plugin {
|
||||
// ignore
|
||||
}
|
||||
|
||||
// Skip static assets
|
||||
if (/\.(woff2?|ttf|otf|eot)$/.test(fullURL.pathname)) {
|
||||
// Externalize static assets
|
||||
const ext = extname(fullURL.pathname).slice(1);
|
||||
if (ext && !["ts", "tsx", "js", "jsx", "mjs", "cjs", "css", "json"].includes(ext)) {
|
||||
return {
|
||||
path: fullURL.toString(),
|
||||
external: true,
|
||||
|
||||
@@ -71,8 +71,12 @@ export function fsPlugin(fs: JSRuntimeFS, cwd: string): Plugin {
|
||||
|
||||
const ext = extname(path).slice(1);
|
||||
|
||||
if (!["ts", "tsx", "js", "jsx", "css", "json"].includes(ext)) {
|
||||
return;
|
||||
// Handle static assets
|
||||
if (!["ts", "tsx", "js", "jsx", "mjs", "cjs", "css", "json"].includes(ext)) {
|
||||
return {
|
||||
contents: await fs.readFile(path),
|
||||
loader: "file",
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
Reference in new issue
Block a user