question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Question: Excluding antd lib normalize.less from the build

See original GitHub issue

This is rather a question than an issue by itself.

I’ve built a small plugin for a third party service. This plugin uses antd for its design elements. However, the natural problem is that antd includes normalize.less into the final build, which in turn messes with the original page css settings by overriding them.

Would there be a way to specify a means to exclude specific *.less files?

One of the solutions that I currently am using is just reading the document.head and picking the generated style node, where I just clean up the unnecessary CSS through regex. But it seems like a hassle to run a prep script each before each initialisation of the app.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
GuillaumeLeclerccommented, Jun 22, 2017

This issue should definitely not be closed. The problem is real and persists. The styles should be prefixed and not affect the entire page.

4reactions
robessogcommented, Apr 11, 2017

Hi @benjycui

We try to use antd in a quite large enterprise applicationm, but when antd gets applied it inserts normalize.css into the DOM without any namespacing or so. Thus e.g. our <a> tag gets its blue color from normalize.css, and other elements also get undesired box-sizing and so. This messes up our layout in some places. We don’t really have the option to restyle every page. The best would be if we somehow could exclude it from the javascript bundle created by webpack. Or if you could wrap it into a CSS class that would be also a big help.

Can you please provide me an example for your suggestion:

Try webpack external.

I’ve tried to exclude it from less/style loader like this but it did not work: { test: /\.less$/, loader: "style-loader!css-loader!less-loader", exclude: /normalize/ }

What should be written to the externals? We have these currently in it: externals: { "react": "React", "react-dom": "ReactDOM", "antd": "Antd", "lodash": "_", }

Thanks in advance.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Ant-Design CSS not loading properly
this below import is used my react project with create-react-app cli import 'antd/dist/antd.css', use this import to your root component.
Read more >
antd-mobile-without-normalize
A configurable Mobile UI specification and React-based implementation. Features. Follow Ant Design Mobile UI specification. Configurable UI ...
Read more >
Advanced Normalization Tools (ANTS)
6.1 How to build ANTs/ANTsR for users who are new to scientific computing . ... ANTs serves as both a core library for...
Read more >
Antd 2.0 released in English - the best React components library
I've been thinking of trying antd but is it really ready for a production environment? I've been using bootstrap, which everyone would agree...
Read more >
Transfer Learning for Computer Vision Tutorial
The problem we're going to solve today is to train a model to classify ants ... Data augmentation and normalization for training #...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found