Skip to content

Commit

Permalink
fix(storybook): apply a webpack tweak for storybook and angular (#8392)
Browse files Browse the repository at this point in the history
* fix(storybook): apply a webpack tweak for storybook and angular

- [x] remove html raw-loader from the webpack rules array if storybook is used with angular v13;

the html raw-loader breaks jit compilation when storybook 6.5 aplha is used with angular v13

ISSUES CLOSED: #8360

fix(testing): update storybook generator configuration snapshot

fix(testing): update storybook generator configuration snapshot, use the flag --update-snapshot

fix(testing): update storybook generator configuration snapshot, test affected, update snapshot

* cleanup(storybook): make the webpack tweak for storybook and angular explanation more concise
  • Loading branch information
rfprod committed Jan 6, 2022
1 parent 22c6ddb commit 77529a1
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 2 deletions.
Expand Up @@ -20,7 +20,18 @@ module.exports = {
if (rootMain.webpackFinal) {
config = await rootMain.webpackFinal(config, { configType });
}
// remove html raw-loader that breaks Jit compilation
const rules = (config.module.rules ?? []).filter(
(rule) =>
rule.test !== /\\\\.html$/ &&
rule.exclude !== /\\\\.async\\\\.html$/ &&
!rule.loader?.includes('raw-loader')
);
config.module.rules = [...rules];
// add your own webpack tweaks if needed
Expand Down
Expand Up @@ -20,7 +20,18 @@ module.exports = {
if (rootMain.webpackFinal) {
config = await rootMain.webpackFinal(config, { configType });
}
// remove html raw-loader that breaks Jit compilation
const rules = (config.module.rules ?? []).filter(
(rule) =>
rule.test !== /\\\\.html$/ &&
rule.exclude !== /\\\\.async\\\\.html$/ &&
!rule.loader?.includes('raw-loader')
);
config.module.rules = [...rules];
// add your own webpack tweaks if needed
Expand Down Expand Up @@ -59,13 +70,24 @@ module.exports = {
if (rootMain.webpackFinal) {
config = await rootMain.webpackFinal(config, { configType });
}
// for backwards compatibility call the \`rootWebpackConfig\`
// this can be removed once that one is migrated fully to
// use the \`webpackFinal\` property in the \`main.js\` file
config = rootWebpackConfig({ config });
// remove html raw-loader that breaks Jit compilation
const rules = (config.module.rules ?? []).filter(
(rule) =>
rule.test !== /\\\\.html$/ &&
rule.exclude !== /\\\\.async\\\\.html$/ &&
!rule.loader?.includes('raw-loader')
);
config.module.rules = [...rules];
// add your own webpack tweaks if needed
return config;
Expand Down
Expand Up @@ -17,13 +17,24 @@ module.exports = {
if (rootMain.webpackFinal) {
config = await rootMain.webpackFinal(config, { configType });
}

<% if (existsRootWebpackConfig) { %>// for backwards compatibility call the `rootWebpackConfig`
// this can be removed once that one is migrated fully to
// use the `webpackFinal` property in the `main.js` file
config = rootWebpackConfig({ config });
<% } %>

<% if (uiFramework === '@storybook/angular') { %>
// remove html raw-loader that breaks Jit compilation
const rules = (config.module.rules ?? []).filter(
(rule) =>
rule.test !== /\.html$/ &&
rule.exclude !== /\.async\.html$/ &&
!rule.loader?.includes('raw-loader')
);
config.module.rules = [...rules];
<% } %>

// add your own webpack tweaks if needed

return config;
Expand Down

0 comments on commit 77529a1

Please sign in to comment.