create-react-component-library/.storybook/main.js

67 lines
1.6 KiB
JavaScript
Raw Normal View History

2022-05-30 12:46:55 -06:00
const path = require('path');
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
2023-06-26 21:08:57 -06:00
const deFaultValues = {
PREFIX_URL: ''
}
const prefixUrl = process.env.PREFIX_URL ? process.env.PREFIX_URL : deFaultValues.PREFIX_URL
2022-05-30 12:46:55 -06:00
module.exports = {
2023-03-28 17:36:47 -06:00
"stories": ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|ts|tsx)"],
"addons": [
"@storybook/addon-links",
"@storybook/addon-essentials",
"@storybook/addon-interactions",
{
name: '@storybook/preset-scss',
options: {
cssLoaderOptions: {
modules: {
auto: /\.module\.\w+$/i,
}
}
}
}
],
2022-05-30 12:46:55 -06:00
"webpackFinal": async config => {
config.module.rules.push(
{
test: /\.(ts|tsx)$/,
use: [
{
loader: 'ts-loader',
options: {
transpileOnly: true,
},
},
],
}
);
2023-06-26 21:08:57 -06:00
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;
}),
2023-03-28 17:36:47 -06:00
config.resolve.alias = {
...config.resolve.alias,
2022-05-30 12:46:55 -06:00
'@components': path.resolve(__dirname, "../src/components/")
};
config.resolve.plugins = [new TsconfigPathsPlugin()];
return config;
},
2023-03-28 17:36:47 -06:00
"framework": {
name: "@storybook/react-webpack5",
options: {}
2022-05-30 12:46:55 -06:00
},
typescript: {
reactDocgenTypescriptOptions: {
compilerOptions: {
"paths": {
2023-03-28 17:36:47 -06:00
"@Components/*": ["Components/*"]
}
2022-05-30 12:46:55 -06:00
}
}
},
2023-03-28 17:36:47 -06:00
docs: {
autodocs: true
}
};