Skip to content

Commit

Permalink
Fix storybook
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobwgillespie committed Dec 22, 2022
1 parent 22cd38d commit ad7bb0c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
18 changes: 18 additions & 0 deletions .storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,22 @@ module.exports = {
core: {
builder: 'webpack5',
},

webpackFinal: async (config) => {
config.module.rules = config.module.rules.map((rule) => {
if (rule.type === 'asset/resource') {
// Removing the rule for SVGs
rule.test = /\.(ico|jpg|jpeg|png|apng|gif|eot|otf|webp|ttf|woff|woff2|cur|ani|pdf)(\?.*)?$/
}
return rule
})

config.module.rules.push({
test: /\.svg$/,
use: 'raw-loader',
})

console.log(config.module.rules)
return config
},
}
9 changes: 5 additions & 4 deletions tools/builder/build-pack.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,15 @@ const generate = async () => {
await fs.writeFile(
'icons.stories.js',
`
import {storiesOf} from '@storybook/html'
export default {
title: '${path.basename(baseDir)}',
}
storiesOf('${path.basename(baseDir)}')
.add('icons', () => [
export const icons = () => [
${icons
.map((icon) => ` ['${icon.originalName}', require('!!raw-loader!./${icon.originalName}.svg').default],`)
.join('\n')}
].map(icon => \`<div>\${icon[0]}</div><div class="icon">\${icon[1]}</div>\`).join('\\n'))
].map(icon => \`<div>\${icon[0]}</div><div class="icon">\${icon[1]}</div>\`).join('\\n')
`.trim(),
)
Expand Down

0 comments on commit ad7bb0c

Please sign in to comment.