Skip to content

Commit

Permalink
Merge pull request #20287 from storybookjs/valentin/fix-angular-15.0.…
Browse files Browse the repository at this point in the history
…4-webpack-require-issue

Support Angular 15.0.4
  • Loading branch information
ndelangen authored and shilman committed Dec 20, 2022
1 parent df77385 commit 8a5baec
Showing 1 changed file with 19 additions and 14 deletions.
Expand Up @@ -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;
});
Expand Down

0 comments on commit 8a5baec

Please sign in to comment.