From 57d967dfaffd1313cc780fdfa79c494efc6b4146 Mon Sep 17 00:00:00 2001 From: Valentin Palkovic Date: Thu, 15 Dec 2022 12:02:43 +0100 Subject: [PATCH] Support Angular 15.0.4 --- ...torybook-normalize-angular-entry-plugin.js | 33 +++++++++++-------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/code/frameworks/angular/src/server/plugins/storybook-normalize-angular-entry-plugin.js b/code/frameworks/angular/src/server/plugins/storybook-normalize-angular-entry-plugin.js index a390d0e4b938..9d36fc8893e7 100644 --- a/code/frameworks/angular/src/server/plugins/storybook-normalize-angular-entry-plugin.js +++ b/code/frameworks/angular/src/server/plugins/storybook-normalize-angular-entry-plugin.js @@ -25,23 +25,28 @@ export default class StorybookNormalizeAngularEntryPlugin { } apply(compiler) { - const webpackOptions = compiler.options; - const entry = - typeof webpackOptions.entry === 'function' ? webpackOptions.entry() : webpackOptions.entry; + compiler.hooks.environment.tap(PLUGIN_NAME, () => { + const webpackOptions = compiler.options; + const entry = + typeof webpackOptions.entry === 'function' ? webpackOptions.entry() : webpackOptions.entry; - webpackOptions.entry = async () => { - const entryResult = await entry; + webpackOptions.entry = async () => { + const entryResult = await entry; - if (entryResult.main && entryResult.styles) { - return { - main: { - import: Array.from(new Set([...entryResult.main.import, ...entryResult.styles.import])), - }, - }; - } + if (entryResult.main && entryResult.styles) { + return { + main: { + import: Array.from( + new Set([...entryResult.main.import, ...entryResult.styles.import]) + ), + }, + }; + } + + return entry; + }; + }); - return entry; - }; compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation) => { this.compilation = compilation; });