【发布时间】:2018-11-27 20:08:39
【问题描述】:
最近安装了ant design https://ant.design/
但是,它不使用样式化组件,只使用旧的基本 css 模块。 .css 文件就像 10k 行。有一种方法可以只使用你需要的这些,但首先你必须安装 babel。
不幸的是,我没有在我的项目中使用 babel,只是打字稿。
https://ant.design/docs/react/introduce - 这里写着我需要 babel 和 babel-import-plugin。但正如我所说,我没有使用它,也不想在我的项目中使用它。
对于那些不想进入外部网站的人:
Use modularized antd#
Use babel-plugin-import (Recommended)
// .babelrc or babel-loader option
{
"plugins": [
["import", { "libraryName": "antd", "libraryDirectory": "es", "style": "css" }] // `style: true` for less
]
}
问题:有没有办法使用 typescript 或仅使用 webpack 等来使用模块化 css(仅导入您需要的这些样式)?没有通天塔?
谢谢
【问题讨论】:
标签: javascript css webpack babeljs antd