

如何在 And Design Pro 或 UmiJS 中使用 tailwindcss
source link: http://overtrue.me/articles/2020/01/use-tailwindcss-in-and-design-pro.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

最近打算给已有的项目做个管理后台,找了一圈以后开箱即用又好看的,实属 Ant Design Pro 了,就像它的 Slogan 一样:“开箱即用的中台前端/设计解决方案”。不过对于 React 还不算入门的我,一路摸着石头过河,作为 Tailwindcss 死忠粉,尝试了在 Ant Design Pro 中集成它,这里分享给同样喜欢这俩的朋友。
Ant Design Pro 是基于 UmiJS 构建的,所以,如果你在使用 UmiJS,方法是完全一样的。
安装 tailwindcss 和常用 postcss 插件
$ yarn add tailwindcss postcss-import postcss-nested autoprefixer
在 src
下创建 tailwind.css
src/tailwind.css
@import 'tailwindcss/base'; @import 'tailwindcss/components'; @import 'tailwindcss/utilities';
修改配置
在 config/config.js 中增加配置项 extraPostCSSPlugins
:
//... extraPostCSSPlugins: [ require('postcss-import'), require('tailwindcss'), require('postcss-nested'), // or require('postcss-nesting') require('autoprefixer'), ], //...
全局引入 tailwindcss
你可以在你觉得合适的地方全局引入上面创建的 tailwind.css
,比如在 src/global.less
中引入:
@import '~antd/es/style/themes/default.less'; @import 'tailwind.css'; //...
然后你就可以在我们的页面使用了:
<div className="mt-4"> <div className="mb-3"> ...
好了,搞定!
Recommend
-
186
umi - ? Blazing-fast next.js-like framework for React apps.
-
43
README.md
-
20
README.md English | 简体中文 umi-request The network request library, bas...
-
8
father Library toolkit based on rollup, docz, storybook, jest, prettier and eslint. 视频教程:利用 umi-library(father) 做组件打包。 Features ✔︎ 基...
-
10
You might think that these things don't belong in the same article, but here we are, this week in front-end development, having the same conversation that seems to be never-ending. There's a complexity here that I fi...
-
8
Setting up the app Creating a Next.js app npx create-next-app next-tailwind-ts-demo Enter fullscreen modeExit fullscreen mode Starting the app...
-
4
@raivikasVikas RaiCollege student at Maharaja Agrasen Institute of Technology||Web Developer || Next.js Lover || React.js || TailwindCSSThis blog...
-
6
-
11
Tailwind CSS 是最近几年很火的 CSS UI 框架,遵循 Atomic/Utility-First 的原则,能够大幅提升样式开发效率。在本篇博客中,我将介绍 UmiJS 项目接入 Tailwind CSS 的流程,并分享遇到...
-
3
为什么越来越多的人开始选择使用Tailwindcss更新日期: 2022-04-26阅读量: 5标签: 框架分享
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK