SolidZORO / next-plugin-antd-less

🎩 Use Antd (Less) with Next.js v12, Zero Dependency on other Next-Plugins.
MIT License
345 stars 48 forks source link

How to avoid modifying global styles? #8

Closed salihozdemir closed 3 years ago

salihozdemir commented 3 years ago

If i need to integrate ant-design as a part of an existing website, it's likely i want to prevent ant-design to override global styles. How can i do this?

image

Can we prevent global.less from loading?

SolidZORO commented 3 years ago

what file is this global.less? Is it from antd?

salihozdemir commented 3 years ago

Yes it comes from antd. I couldn't find a solution other than overriding.

SolidZORO commented 3 years ago

you can try

// .babelrc.js

plugins: [
    [
      'import',
      {
        libraryName: 'antd',
        style: false,   <--- edit this line to `false`
      },
    ]
  ],

and create antd-reset.less, like this:

@import '~antd/es/style/themes/index.less';
//@import '~antd/es/style/core/index.less';

@import '~antd/es/style/mixins/index.less';
//@import '~antd/es/style/core/base.less';
//@import '~antd/es/style/core/iconfont.less';
@import '~antd/es/style/core/motion.less';

// ...
salihozdemir commented 3 years ago

I created the reset-antd.less then imported it in _appjs. It's work perfectly yarn dev but when i build my project styles of ant components are not loaded. Is the less format in app.js the problem or is it adding a css globally? What should I do? I just couldn't find.

15520065 commented 2 years ago

@salihozdemir Have you find the solution yet?