transitive-bullshit / create-react-library

CLI for creating reusable react libraries.
https://transitivebullsh.it/javascript-dev-tools-in-2022
4.78k stars 300 forks source link

CSS import is affecting global scope #140

Closed devth closed 4 years ago

devth commented 5 years ago

I'm importing Bulma in my component:

import bulma from './bulma.css';

But when I include that component in another app it's injecting global bulma stuff into the entire site. I expected it to be scoped by default.

Component is here. I'm using default config from CRL.

The injected css can be seen in the <head> section of https://yetibot.com/community where this component is being used. It includes a bunch of (expected) scoped rules like:

.bulma_is-active__2ghUu.bulma_pagination-ellipsis__2wvrz {
  outline: none;
}

but it also globally includes Bulma's minireset without scopes, like:

/*! minireset.css v0.0.4 | MIT License | github.com/jgthms/minireset.css */
html,
body,
p,
ol,
ul,
li,
dl,
dt,
dd,
blockquote,
figure,
fieldset,
legend,
textarea,
pre,
iframe,
hr,
h1,
h2,
h3,
h4,
h5,
h6 {
  margin: 0;
  padding: 0;
}

Any idea how to avoid importing Bulma's reset globally? (Note: bulma is already included on this site so this just duplicates existing rules but it also overrides some of the customizations I had made in the site that hosts the component).

transitive-bullshit commented 4 years ago

v3 changes how CSS is handled so you can import the generated CSS manually and have more control over things.

If you're still experiencing issues with v3, please open a new issue.

Thanks!