From 2d6381d60a063ebdd58b7869bdab278697bcfed5 Mon Sep 17 00:00:00 2001 From: leex Date: Wed, 3 Apr 2024 19:54:23 +0800 Subject: [PATCH] feat(serverAssets): support `ignore` option (#2302) --- src/rollup/plugins/server-assets.ts | 3 ++- src/types/nitro.ts | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/rollup/plugins/server-assets.ts b/src/rollup/plugins/server-assets.ts index 753ad41893..57b8e776ad 100644 --- a/src/rollup/plugins/server-assets.ts +++ b/src/rollup/plugins/server-assets.ts @@ -46,6 +46,7 @@ export function serverAssets(nitro: Nitro): Plugin { const files = await globby("**/*.*", { cwd: asset.dir, absolute: false, + ignore: asset.ignore, }); for (const _id of files) { const fsPath = resolve(asset.dir, _id); @@ -78,7 +79,7 @@ const serverAssets = ${JSON.stringify(nitro.options.serverAssets)} export const assets = createStorage() for (const asset of serverAssets) { - assets.mount(asset.baseName, fsDriver({ base: asset.dir })) + assets.mount(asset.baseName, fsDriver({ base: asset.dir, ignore: (asset?.ignore || []) })) }`; } diff --git a/src/types/nitro.ts b/src/types/nitro.ts index 441719c94e..d2d693d45f 100644 --- a/src/types/nitro.ts +++ b/src/types/nitro.ts @@ -159,6 +159,7 @@ export interface PublicAssetDir { export interface ServerAssetDir { baseName: string; dir: string; + ignore?: string[]; } export interface DevServerOptions {