diff --git a/packages/angular/src/generators/storybook-configuration/__snapshots__/storybook-configuration.spec.ts.snap b/packages/angular/src/generators/storybook-configuration/__snapshots__/storybook-configuration.spec.ts.snap index aae8d650590b7..46a19bbad6ed8 100644 --- a/packages/angular/src/generators/storybook-configuration/__snapshots__/storybook-configuration.spec.ts.snap +++ b/packages/angular/src/generators/storybook-configuration/__snapshots__/storybook-configuration.spec.ts.snap @@ -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 diff --git a/packages/storybook/src/generators/configuration/__snapshots__/configuration.spec.ts.snap b/packages/storybook/src/generators/configuration/__snapshots__/configuration.spec.ts.snap index 712c1ac5d533a..7435a90b7da8d 100644 --- a/packages/storybook/src/generators/configuration/__snapshots__/configuration.spec.ts.snap +++ b/packages/storybook/src/generators/configuration/__snapshots__/configuration.spec.ts.snap @@ -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 @@ -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; diff --git a/packages/storybook/src/generators/configuration/project-files/.storybook/main.js__tmpl__ b/packages/storybook/src/generators/configuration/project-files/.storybook/main.js__tmpl__ index 37c8f886b26a1..8c00507838f79 100644 --- a/packages/storybook/src/generators/configuration/project-files/.storybook/main.js__tmpl__ +++ b/packages/storybook/src/generators/configuration/project-files/.storybook/main.js__tmpl__ @@ -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;