create-react-app - 是否可以将 antd 与 create-react-app 2 一起使用?
问题描述
我的理解是 react-app-rewired 不再适用于 create-react-app 的 v2。
看来你需要进入 babel(因此 react-app-rewired)。
解决方案
您可以使用craco代替 react-app-rewired。
以下是一些示例 craco.config.js 配置文件:
更少
Ant 设计 + 更少 + modifyVars
蚂蚁设计 + 更少 + modifyVars + Preact
Preact在 craco repo 的 /recipes 目录中有更多示例。
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 }],
};
推荐阅读
- visual-studio-code - 如何在 Visual Studio Code 的快速打开视图中设置默认选项?
- c++ - 如何将整数列表添加到 sqlite3 的表中
- mysql - 将数据存储到 mysql 时出现错误
- r - 在 RStudio 中,如何制作列数据与行号匹配并被 1 替换,其余被 0 替换的数据矩阵?
- reactjs - 使用 React Router 显示详细信息
- android - Android Studio - 设备文件资源管理器图片目录
- elixir - HTTPoison 在从不同域调用多个端点时使用错误的基本 URL
- python - 使用 python 和 pandas 计算时间并将值推送到 CSV 文件中
- ios - 货币复数 swift 不允许配置
- python - 如何解释 Python 的 subprocess.run 的返回码