2023-12-14 04:41:03 -05:00
|
|
|
import type { StorybookConfig } from '@storybook/react-webpack5'
|
|
|
|
import path from 'node:path'
|
2024-03-25 08:18:38 -04:00
|
|
|
import MiniCssExtractPlugin from 'mini-css-extract-plugin'
|
2023-12-14 04:41:03 -05:00
|
|
|
|
|
|
|
const rootDir = path.resolve(__dirname, '..')
|
|
|
|
|
|
|
|
// NOTE: must be set before webpack config is imported
|
2024-02-06 04:34:15 -05:00
|
|
|
process.env.OVERLEAF_CONFIG = path.join(rootDir, 'config/settings.webpack.js')
|
2023-12-14 04:41:03 -05:00
|
|
|
|
2024-03-25 07:28:20 -04:00
|
|
|
function getAbsolutePath(value: string): any {
|
|
|
|
return path.dirname(require.resolve(path.join(value, 'package.json')))
|
|
|
|
}
|
|
|
|
|
2023-12-14 04:41:03 -05:00
|
|
|
const config: StorybookConfig = {
|
|
|
|
core: {
|
|
|
|
disableTelemetry: true,
|
|
|
|
},
|
|
|
|
staticDirs: [path.join(rootDir, 'public')],
|
|
|
|
stories: [
|
|
|
|
path.join(rootDir, 'frontend/stories/**/*.stories.{js,jsx,ts,tsx}'),
|
|
|
|
path.join(rootDir, 'modules/**/stories/**/*.stories.{js,jsx,ts,tsx}'),
|
|
|
|
],
|
|
|
|
addons: [
|
2024-03-25 07:28:20 -04:00
|
|
|
getAbsolutePath('@storybook/addon-links'),
|
|
|
|
getAbsolutePath('@storybook/addon-essentials'),
|
|
|
|
getAbsolutePath('@storybook/addon-interactions'),
|
|
|
|
getAbsolutePath('@storybook/addon-a11y'),
|
|
|
|
getAbsolutePath('@storybook/addon-webpack5-compiler-babel'),
|
2024-03-25 08:18:38 -04:00
|
|
|
{
|
|
|
|
name: getAbsolutePath('@storybook/addon-styling-webpack'),
|
|
|
|
options: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.css$/,
|
|
|
|
use: [
|
|
|
|
{ loader: MiniCssExtractPlugin.loader },
|
|
|
|
{ loader: 'css-loader' },
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.less$/,
|
|
|
|
use: [
|
|
|
|
{ loader: MiniCssExtractPlugin.loader },
|
|
|
|
{ loader: 'css-loader' },
|
|
|
|
{ loader: 'less-loader' },
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
plugins: [new MiniCssExtractPlugin()],
|
|
|
|
},
|
|
|
|
},
|
2023-12-14 04:41:03 -05:00
|
|
|
],
|
|
|
|
framework: {
|
2024-03-25 07:28:20 -04:00
|
|
|
name: getAbsolutePath('@storybook/react-webpack5'),
|
2023-12-14 04:41:03 -05:00
|
|
|
options: {},
|
|
|
|
},
|
|
|
|
docs: {
|
|
|
|
autodocs: 'tag',
|
|
|
|
},
|
2024-03-25 07:28:20 -04:00
|
|
|
babel: (options: Record<string, any>) => {
|
2023-12-14 04:41:03 -05:00
|
|
|
return {
|
|
|
|
...options,
|
|
|
|
plugins: [
|
|
|
|
// ensure that TSX files are transformed before other plugins run
|
|
|
|
['@babel/plugin-transform-typescript', { isTSX: true }],
|
|
|
|
...(options.plugins ?? []),
|
|
|
|
],
|
|
|
|
}
|
|
|
|
},
|
|
|
|
webpackFinal: storybookConfig => {
|
|
|
|
return {
|
|
|
|
...storybookConfig,
|
|
|
|
resolve: {
|
|
|
|
...storybookConfig.resolve,
|
|
|
|
fallback: {
|
|
|
|
...storybookConfig.resolve?.fallback,
|
|
|
|
fs: false,
|
|
|
|
os: false,
|
|
|
|
module: false,
|
|
|
|
},
|
|
|
|
extensions: ['.js', '.jsx', '.mjs', '.ts', '.tsx', '.json'],
|
|
|
|
alias: {
|
|
|
|
...storybookConfig.resolve?.alias,
|
|
|
|
// custom prefixes for import paths
|
|
|
|
'@': path.join(rootDir, 'frontend/js/'),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
export default config
|