storybook/docs/_snippets/web-components-webpack5-transpilation.md
2024-12-03 12:06:05 +01:00

1.1 KiB

export default {
  webpackFinal: async (config) => {
    // Find web-components rule for extra transpilation
    const webComponentsRule = config.module.rules.find(
      (rule) => rule.use && rule.use.options && rule.use.options.babelrc === false,
    );
    // Add your own `my-library`
    webComponentsRule.test.push(new RegExp(`node_modules(\\/|\\\\)my-library(.*)\\.js$`));

    return config;
  },
};
import type { StorybookConfig } from '@storybook/web-components-webpack5';

const config: StorybookConfig = {
  webpackFinal: async (config) => {
    // Find web-components rule for extra transpilation
    const webComponentsRule = config.module.rules.find(
      (rule) => rule.use && rule.use.options && rule.use.options.babelrc === false,
    );
    // Add your own `my-library`
    webComponentsRule.test.push(new RegExp(`node_modules(\\/|\\\\)my-library(.*)\\.js$`));

    return config;
  },
};

export default config;