Is it possible to use antd with create-react-app 2?

Viewed 454

My understanding is react-app-rewired no longer works in v2 of create-react-app.

It seems you need to get into babel (thus react-app-rewired).

1 Answers

You can use craco instead of react-app-rewired.

Information from react-app-rewired issue comments:

Here are some example craco.config.js configuration files:

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

There are some more examples in the /recipes directory in the craco repo.

Example of craco.config.js from 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 }],
};
Related