【问题标题】:Is it possible to use antd with create-react-app 2?是否可以将 antd 与 create-react-app 2 一起使用?
【发布时间】:2019-04-12 03:08:44
【问题描述】:

我的理解是 react-app-rewired 不再适用于 create-react-app 的 v2。

看来你需要进入 babel(因此 react-app-rewired)。

【问题讨论】:

    标签: create-react-app antd


    【解决方案1】:

    您可以使用 craco 代替 react-app-rewired。

    来自react-app-rewired issue comments的信息:

    这里有一些示例 craco.config.js 配置文件:

    Less
    Ant Design + Less + modifyVars
    Ant Design + Less + modifyVars + Preact
    Preact

    some more examples in the /recipes directory in the craco repo

    craco.config.js 的示例来自ndbroadbent

    const CracoAntDesignPlugin = require('craco-antd');
    const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
    const WebpackBar = require('webpackbar');
    
    module.exports = {
      webpack: {
        alias: { react: 'preact-compat', 'react-dom': 'preact-compat' },
        plugins: [
          new BundleAnalyzerPlugin(),
          new WebpackBar({ profile: true }),
        ],
      },
      plugins: [{ plugin: CracoAntDesignPlugin }],
    };
    

    【讨论】:

      猜你喜欢
      • 2020-02-03
      • 2017-09-14
      • 2019-01-30
      • 1970-01-01
      • 2022-01-10
      • 2021-12-08
      • 2017-10-26
      • 2021-01-30
      • 2019-02-05
      相关资源
      最近更新 更多