soso-tip icon indicating copy to clipboard operation
soso-tip copied to clipboard

storybook config (feat. yarn2)

Open SoYoung210 opened this issue 3 years ago โ€ข 0 comments

postcss 8์ด ๋ฆด๋ฆฌ์ฆˆ๋˜๋ฉด์„œ ๋””ํŽœ๋˜์‹œ๊ฐ€ ์—ฌ๊ธฐ์ €๊ธฐ ์ข…์ข…..๊นจ์ง.. ํŠนํžˆ ์›นํŒฉ4 ๋ชจ๋“œ๋กœ ๋Œ๋ฆฌ๋ฉด ์ตœ์‹  ๋””ํŽœ๋˜์‹œ์™€ ๊ฑฐ์ง„ ํ˜ธํ™˜์ด ์•ˆ๋˜๋Š”๋ฐ..

  • @storybook/addon-postcss๋กœ postcss๋ฒ„์ „์„ ํŒจํ‚ค์ง€ ๋ฒ„์ „์œผ๋กœ ์จ์ฃผ๊ณ 
  • storybook/scss๋ฅผ ์‚ฌ์šฉํ•ด์ฃผ๊ณ 
  • (if yarn2) ์˜์กด์„ฑ์„ ์ข€ ๋ช…์‹œํ•ด์ฃผ๋ฉด ๋œ๋‹ค.
# yarn2
packageExtensions:
  "@storybook/builder-webpack4@*":
    dependencies:
      "sass-loader": "^10.1.1"
      "node-sass": "^5.0.0"
const { resolve } = require('path');

module.exports = {
  stories: ['../src/**/*.stories.tsx'],
  addons: [
    '@storybook/addon-essentials',
    {
      name: '@storybook/preset-scss',
      sassLoaderOptions: {
        includePaths: 'your_path'
      }
    },
    {
      name: '@storybook/addon-postcss',
      options: {
        rule: {
          test: /\.scss$/,
          sideEffects: true,
        },
        postcssLoaderOptions: {
          implementation: require('postcss'),
          config: 'your_path'
        },
      },
    },
  ],
  webpackFinal: async baseConfig => {
    const { module = {} } = baseConfig;

    const rules = (baseConfig.module.rules || []).filter(f => {
      if (f.test != null) {
        return f.test.toString() !== '/\\.scss$/' && f.test.toString() !== '/\\.(ts|tsx)$/';
      }
      return true
    });

    return {
      ...baseConfig,
      module: {
        ...module,
        rules: [
          ...rules,
          {
            test: /\.(ts|tsx)$/,
            loader: require.resolve('babel-loader'),
            options: {
              configFile: 'your_path'
            },
          },
        ]
      }
    };
  },
};

SoYoung210 avatar May 24 '21 16:05 SoYoung210