是否可以将 antd 与 create-react-app 2 一起使用?
Is it possible to use antd with create-react-app 2?
我的理解是 react-app-rewired 在 create-react-app v2 中不再有效。
看来你需要进入 babel(因此 react-app-rewired)。
您可以使用 craco 而不是 react-app-rewired。
来自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.
来自 ndbroadbent 的 craco.config.js
示例:
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 }],
};
我的理解是 react-app-rewired 在 create-react-app v2 中不再有效。
看来你需要进入 babel(因此 react-app-rewired)。
您可以使用 craco 而不是 react-app-rewired。
来自react-app-rewired issue comments的信息:
Here are some example craco.config.js configuration files:
Less
Ant Design + Less + modifyVars
Ant Design + Less + modifyVars + Preact
PreactThere are some more examples in the /recipes directory in the craco repo.
来自 ndbroadbent 的 craco.config.js
示例:
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 }],
};