Update Ant Design Examples for New CSS Support (9.2)
See original GitHub issueimport ant-design library throw error
can you provide an example import ant-design use [RFC] css support? thanks. when i use [RFC] css support and import ant-design library, it throw error :
./node_modules/antd/lib/button/style/index.css
Global CSS cannot be imported from files other than your Custom <App>. Please move all global CSS imports to pages/_app.js.
here is my next-config.js
module.exports = {
experimental: {
css: true
},
}
Issue Analytics
- State:
- Created 4 years ago
- Reactions:11
- Comments:74 (32 by maintainers)
Top Results From Across the Web
CSS Compatible - Ant Design
Ant Design supports the last 2 versions of modern browsers. If you need to be compatible with legacy browsers, please perform downgrade processing...
Read more >Change Log - Ant Design
Improve Icon component definition to be compatible with create-react-app svg component. ... message added support for updating content with a unique key.
Read more >Change Log - Ant Design
Major Changes · New Components · New Component Variants · New Design · Export object theme which contains hooks and algorithms related with...
Read more >V4 to V5 - Ant Design
This document will help you upgrade from antd 4.x version to antd 5.x version. If you are using 3.x or older version, please...
Read more >Customize Theme - Ant Design
In version 5.0, we provide a new way to customize themes. Different from the less and CSS variables of the 4.x version, with...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@raindecastro Ant-design works by importing all necessary CSS when importing the component. Therefore, if you pass in an option that alters its appearance – like adding the mode=“multiple” option to
Select– then the CSS will already be included. Unfortunately, this has thesideEffectof importing other CSS that may not be in use.The larger problem is that ant-design isn’t a small library (48.3 MB unpacked and about 1.5MB+ packed) and with it are a lot of dependencies. Therefore, lower lighthouse scores are kind of expected when using it. This is one of the main reasons why I’ve slowly migrated away from ant-design to either directly using their react component (rc) dependencies or more recently designing my own UI components.
Take a look at these chunk graphs of

with-ant-design-lessout-of-the-box: Ant-design makes up 2.13MB of 3.11MB (parsed)However… there are two things you can do to reduce the bundle size:
1.) Remove
momentlocales:config.plugins.push(new IgnorePlugin(/^\.\/locale$/, /moment$/));2.) Only export icons from
@ant-design/icons/distthat you need:icons/index.js (if you import other components that require icons, then they’ll need to be manually added to this file)
next.config.js
Take a look at these chunk graphs: Ant-design still makes up 1.2MB of 2.11MB (parsed)

has anybody got working ant design 4 (less) + nextjs 9.2 + avoid conflicting order?