Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(storybook): apply a webpack tweak for storybook and angular #8392

Merged
merged 2 commits into from
Jan 6, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,29 @@ module.exports = {
if (rootMain.webpackFinal) {
config = await rootMain.webpackFinal(config, { configType });
}




/**
* Remove html raw loader that breaks Jit compilation as suggested here https://github.com/storybookjs/storybook/issues/16977#issuecomment-1004059631.
* The issue references:
* - https://github.com/storybookjs/storybook/issues/16977#issuecomment-1003399336
* - https://github.com/storybookjs/storybook/issues/16977#issuecomment-1004180729
* Here's what should be removed:
* {
* test: /\\\\.html$/,
* loader: './node_modules/raw-loader/dist/cjs.js',
* exclude: /\\\\.async\\\\.html$/
* },
*/
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
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,29 @@ module.exports = {
if (rootMain.webpackFinal) {
config = await rootMain.webpackFinal(config, { configType });
}




/**
* Remove html raw loader that breaks Jit compilation as suggested here https://github.com/storybookjs/storybook/issues/16977#issuecomment-1004059631.
* The issue references:
* - https://github.com/storybookjs/storybook/issues/16977#issuecomment-1003399336
* - https://github.com/storybookjs/storybook/issues/16977#issuecomment-1004180729
* Here's what should be removed:
* {
* test: /\\\\.html$/,
* loader: './node_modules/raw-loader/dist/cjs.js',
* exclude: /\\\\.async\\\\.html$/
* },
*/
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 +81,35 @@ 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 as suggested here https://github.com/storybookjs/storybook/issues/16977#issuecomment-1004059631.
* The issue references:
* - https://github.com/storybookjs/storybook/issues/16977#issuecomment-1003399336
* - https://github.com/storybookjs/storybook/issues/16977#issuecomment-1004180729
* Here's what should be removed:
* {
* test: /\\\\.html$/,
* loader: './node_modules/raw-loader/dist/cjs.js',
* exclude: /\\\\.async\\\\.html$/
* },
*/
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
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,35 @@ 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 as suggested here https://github.com/storybookjs/storybook/issues/16977#issuecomment-1004059631.
* The issue references:
* - https://github.com/storybookjs/storybook/issues/16977#issuecomment-1003399336
* - https://github.com/storybookjs/storybook/issues/16977#issuecomment-1004180729
* Here's what should be removed:
* {
* test: /\.html$/,
* loader: './node_modules/raw-loader/dist/cjs.js',
* exclude: /\.async\.html$/
* },
*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think we could make this comment smaller, or maybe remove the github issue references/links, and just keep the explanation? (the Jit breaking, and what needs to be removed for example)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I will remove it in a while once I'm around my laptop.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, no rush! I'll take a look tomorrow my morning in any case! :D

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mandarini I made the change you requested.

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