December 28, 2021
storybook์์ svg react component๋ฅผ ์ฌ์ฉํ๊ธฐ ์ํด @svgr/webpack
์ ์ค์นํ๊ณ .storybook/main.js
์ ๋ค์๊ณผ ๊ฐ์ด ์นํฉ ์ค์ ์ ํด์ฃผ์๋ค.
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin')
module.exports = {
stories: [
'../stories/**/*.stories.mdx',
'../stories/**/*.stories.@(js|jsx|ts|tsx)',
],
addons: [
'@storybook/addon-links',
'@storybook/addon-essentials',
'storybook-addon-next-router',
],
webpackFinal: async config => {
config.resolve.plugins.push(new TsconfigPathsPlugin({}))
config.module.rules.unshift({
test: /\.svg$/,
use: ['@svgr/webpack'],
})
return config
},
}
storybook์ ์คํ์ํค์ ๋ค์๊ณผ ๊ฐ์ ์๋ฌ๊ฐ ๋ฐ์ํ๋ค.
TypeError: this.getOptions is not a function
์ฐพ์๋ณด๋ Vue์์ sass/loader ๊ด๋ จ ์๋ฌ๋ง ๋์ค๊ณ storybook ๊ด๋ จํ ๋ฌธ์ ๋ ๋์ค์ง ์์๋ค. storybook github issue์ ๋ฑ๋ก๋ ์๋ฃจ์
์ ๋คํด๋ดค์ง๋ง ํด๊ฒฐ์ด ์๋๋ ์ค @svgr/webpack github ์ด์์์ ๋์ผํ ์๋ฌ๋ฅผ ๋ฐ๊ฒฌํ ์ ์์๋ค. https://github.com/gregberge/svgr/issues/631
@svgr/webpack v6์ ๋ฌธ์ ๋ก ๋ฒ์ ์ v5.5.0์ผ๋ก ๋ฎ์ถฐ์ฃผ๊ณ ๋ค์ ์คํ์ํค๋ฉด ์ ๋์๊ฐ๋ค.
svg ReactCompoment๋ ์ ๋์ค๋ ๊ฒ์ ํ์ธํ ์ ์๋ค.