From bd843e5317b796630a72074282c91f708e9fa727 Mon Sep 17 00:00:00 2001 From: Erin Date: Fri, 28 Jul 2023 05:28:06 -0400 Subject: [PATCH] clean up manifest step more --- index.mjs | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/index.mjs b/index.mjs index f5130ad..d22e7bb 100644 --- a/index.mjs +++ b/index.mjs @@ -129,28 +129,21 @@ export function buildConfig ({ }, plugins: [ { + // emit other assets buildStart () { - assets.forEach(absolutePath => { - this.emitFile({ - type: 'asset', - fileName: getOutputFilename(absolutePath), - source: readFileSync(absolutePath), - }); - }); - }, - load (id) { - if (id === manifestPath) { - // throwaway contents, replaced later - return 'debugger;'; - } - return null; - }, - renderChunk (code, chunk) { - if (chunk.facadeModuleId !== manifestPath) { - return null; - } - return JSON.stringify(manifestContent, null, '\t'); + assets.forEach(absolutePath => this.emitFile({ + type: 'asset', + fileName: getOutputFilename(absolutePath), + source: readFileSync(absolutePath), + })); }, + + // hacks to make sure the manifest is emitted as bare JSON + load: id => id === manifestPath ? 'debugger;' : null, + renderChunk: (_, chunk) => + chunk.facadeModuleId === manifestPath + ? JSON.stringify(manifestContent, null, '\t') + : null, }, ], },