Files
create-react-component-library/.storybook/main.js
Alejandro Lembke Barrientos 6c3dd344e6 PR-733704: update dependencies to latest, bump to v1.4.1
- Bump version 1.4.0 → 1.4.1
- Upgrade Babel 7 → 8 (@babel/core, preset-env, preset-react,
  preset-typescript, register)
- Add ts-node devDependency (webpack-cli needs it to load
  webpack.config.ts now that @babel/register v8 removed .hook)
- Replace __dirname with path.resolve() in webpack.config.ts and
  webpack.cy.config.ts (ESM-safe, no __dirname needed)
- Add npm overrides: force @babel/core ^8 for ts-jest (peerOptional
  conflict) and js-yaml ^4.2.0 to fix GHSA-h67p-54hq-rp68 DoS vuln
- Add babel hook in .storybook/main.js to strip bugfixes option that
  Storybook injects into @babel/preset-env (removed in Babel 8)
- Patch Storybook addons 10.4.3 → 10.4.6, @types/node v25→v26,
  globals v16→v17, sass minor, ts-loader patch, typescript-eslint patch
- 0 npm audit vulnerabilities
2026-06-21 05:40:41 +00:00

107 lines
2.8 KiB
JavaScript

const path = require('path');
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
const deFaultValues = {
PREFIX_URL: ''
};
const prefixUrl = process.env.PREFIX_URL ? process.env.PREFIX_URL : deFaultValues.PREFIX_URL;
module.exports = {
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'],
addons: ['@storybook/addon-webpack5-compiler-babel', '@storybook/addon-links', {
name: '@storybook/addon-styling-webpack',
options: {
rules: [
{
test: /\.(css|sass|scss)$/,
use: [
'style-loader',
{
loader: 'css-loader',
options: {
modules: {
namedExport: false,
exportLocalsConvention: 'as-is',
auto: /\.module\.\w+$/i,
}
},
},
'sass-loader',
],
}
]
},
}, '@storybook/addon-docs'],
webpackFinal: async config => {
config.entry = config.entry.map(function(entry) {
if (entry.includes('webpack-hot-middleware')) {
return `${require.resolve('webpack-hot-middleware/client')}?path=${prefixUrl}__webpack_hmr&reload=true`;
}
return entry;
});
config.resolve.alias = {
...config.resolve.alias,
'@components': path.resolve(__dirname, '../src/components/')
};
config.resolve.plugins = [new TsconfigPathsPlugin()];
return config;
},
framework: {
name: '@storybook/react-webpack5',
options: {}
},
typescript: {
reactDocgenTypescriptOptions: {
compilerOptions: {
'paths': {
'@Components/*': ['Components/*']
}
},
propFilter: (prop) => {
// Filter out props that might contain Symbol values
if (prop.name && typeof prop.name === 'symbol') {
return false;
}
// Filter out React internal props that might cause issues
if (prop.name && prop.name.startsWith('$$')) {
return false;
}
return true;
}
}
},
docs: {
autodocs: 'tag',
defaultName: 'Docs',
},
// Babel 8 removed the `bugfixes` option from @babel/preset-env (it's now always on).
// Storybook injects bugfixes:true in its internal overrides AFTER babelDefault, so we
// strip it here in the `babel` hook which runs after all presets have composed the config.
async babel(config) {
const stripBugfixes = preset => {
if (!Array.isArray(preset)) return preset;
const [name, options] = preset;
if (typeof name === 'string' && name.includes('@babel/preset-env') && options?.bugfixes !== undefined) {
const { bugfixes: _removed, ...rest } = options;
return [name, rest];
}
return preset;
};
if (config.presets) {
config.presets = config.presets.map(stripBugfixes);
}
if (config.overrides) {
config.overrides = config.overrides.map(override => {
if (!override.presets) return override;
return { ...override, presets: override.presets.map(stripBugfixes) };
});
}
return config;
},
};