1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-06-29 00:57:50 +02:00
market/.storybook/main.js
EnzoVezzaro 593039f894
Fix svgr in storybook & jest (#1428)
* fix svg loader

* added Logo component to be able to test storybook

* added svg mock for svgr as suggested (still not working)

* package cleanup

* make svg moduleNameMapper match first

* cleanup

Co-authored-by: Matthias Kretschmann <m@kretschmann.io>
2022-05-16 17:11:43 +01:00

53 lines
1.4 KiB
JavaScript

const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin')
module.exports = {
core: { builder: 'webpack5' },
stories: ['../src/**/*.stories.tsx'],
addons: ['@storybook/addon-essentials'],
framework: '@storybook/react',
webpackFinal: async (config) => {
config.resolve.plugins = [
...(config.resolve.plugins || []),
new TsconfigPathsPlugin({
extensions: config.resolve.extensions
})
]
// Mimic next.config.js webpack config
config.module.rules.push({
test: /\.gif$/,
// yay for webpack 5
// https://webpack.js.org/guides/asset-management/#loading-images
type: 'asset/resource'
})
// Modify storybook's file-loader rule to avoid conflicts with svgr
const fileLoaderRule = config.module.rules.find(
(rule) => rule.test && rule.test.test('.svg')
)
fileLoaderRule.exclude = /\.svg$/
config.module.rules.push({
test: /\.svg$/,
issuer: /\.(tsx|ts)$/,
use: [
{ loader: require.resolve('@svgr/webpack'), options: { icon: true } }
]
})
const fallback = config.resolve.fallback || {}
Object.assign(fallback, {
http: require.resolve('stream-http'),
https: require.resolve('https-browserify'),
fs: false,
crypto: false,
os: false,
stream: false,
assert: false
})
config.resolve.fallback = fallback
return config
}
}