Storybook doesn't understand import on demand for antd components

后端 未结 3 993
鱼传尺愫
鱼传尺愫 2021-01-18 02:49

I have followed instructions here to get antd working fine with CRA. But while using it from storybook, I was getting an <

3条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-18 03:14

    I'm currently using storybook with antd and i got it to play nice, by using this config in my webpack.config.js file in the .storybook folder:

    const { injectBabelPlugin } = require('react-app-rewired');
    const path = require("path");
    
    module.exports = function override(config, env) {
    config = injectBabelPlugin(
    ['import', { libraryName: 'antd', libraryDirectory: 'es', style: 'css' }],
    config,
    );
    
    
    
    config.module.rules.push({
      test: /\.css$/,
      loaders: ["style-loader", "css-loader", ],
      include: path.resolve(__dirname, "../")
      })
    
    
    return config;
    };
    

提交回复
热议问题