diff --git a/src/cli/index.ts b/src/cli/index.ts index 4da8cd33..42c70f23 100644 --- a/src/cli/index.ts +++ b/src/cli/index.ts @@ -157,9 +157,11 @@ export const optimizeImages = async ({ }: OptimizeImagesProps) => { const destDir = path.resolve(cwd, config.outDir ?? 'out') - let manifest: Manifest + let manifest: Manifest = [] try { - manifest = uniqueItems(processManifest(await fs.readFile(manifestJsonPath, 'utf-8'))) + if (fs.existsSync(manifestJsonPath)) { + manifest = uniqueItems(processManifest(await fs.readFile(manifestJsonPath, 'utf-8'))) + } } catch (error) { throw Error(typeof error === 'string' ? error : 'Unexpected error.') } diff --git a/src/loader/index.ts b/src/loader/index.ts index 672b0271..4503b302 100644 --- a/src/loader/index.ts +++ b/src/loader/index.ts @@ -16,7 +16,7 @@ type LoaderOptions = { } export default async function loader(this: LoaderContext, content: string) { - this.cacheable && this.cacheable() + this.cacheable && this.cacheable(false) const callback = this.async() const { dir, isDev } = this.getOptions()