feat: add support for custom static folder in FreshOptions (#626)
Support custom (user provided) static assets folder or fallback to default behavior.
This commit is contained in:
@@ -244,7 +244,10 @@ export class ServerContext {
|
||||
|
||||
const staticFiles: StaticFile[] = [];
|
||||
try {
|
||||
const staticFolder = new URL("./static", manifest.baseUrl);
|
||||
const staticFolder = new URL(
|
||||
opts.staticDir ?? "./static",
|
||||
manifest.baseUrl,
|
||||
);
|
||||
// TODO(lucacasonato): remove the extranious Deno.readDir when
|
||||
// https://github.com/denoland/deno_std/issues/1310 is fixed.
|
||||
for await (const _ of Deno.readDir(fromFileUrl(staticFolder))) {
|
||||
|
||||
@@ -9,6 +9,7 @@ export type StartOptions = ServeInit & FreshOptions;
|
||||
export interface FreshOptions {
|
||||
render?: RenderFunction;
|
||||
plugins?: Plugin[];
|
||||
staticDir?: string;
|
||||
}
|
||||
|
||||
export type RenderFunction = (
|
||||
|
||||
Reference in New Issue
Block a user