(compiler)
| 46 | } |
| 47 | |
| 48 | apply(compiler) { |
| 49 | compiler.hooks.afterEmit.tap(this.constructor.name, async compilation => { |
| 50 | const dist = compilation.outputOptions.path; |
| 51 | const path = `${dist}/manifest.json`; |
| 52 | const manifest = await buildManifest(); |
| 53 | const bgId = 'background/index'; |
| 54 | const bgEntry = compilation.entrypoints.get(bgId); |
| 55 | const scripts = bgEntry.chunks.flatMap(c => [...c.files]); |
| 56 | if (`${manifest.background.scripts}` !== `${scripts}`) { |
| 57 | manifest.background.scripts = scripts; |
| 58 | await fs.writeFile(path, |
| 59 | JSON.stringify(manifest, null, this.minify ? 0 : 2), |
| 60 | { encoding: 'utf8' }); |
| 61 | } |
| 62 | }); |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | exports.readManifest = readManifest; |
no test coverage detected