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.

:global gets added to typography classes over and over again

See original GitHub issue

how to reproduce

  • uncomment config: "tailwind.config.js" in example/svelte/rollup.config.js
// example/svelte/rollup.config.js
...
 preprocess: windicss.preprocess({
        config: "tailwind.config.js",
        // bundle: './public/windi.css',
        // compile: true,
        prefix: "windi-",
        globalPreflight: true,
        globalUtility: true,
      }),
...
  • add only the typography plugin in “tailwind.config.js”
// example/svelte/tailwind.config.js

module.exports = {
  plugins: [
    require("windicss/plugin/typography"),
  ],
};
  • add some markup with .prose in example/svelte/src/App.svelte
<div class="prose">
  <h1>Hello Windicss!</h1>
  <p>lorem</p>
</div>
  • start dev server npm i npm run dev
  • now start editing App.svelte with markup and / or classes

what behavior is expected

I expect to see the markup formated with the prose definitions

what happens instead

On the first run all prose related classed get generated like expected in bundle.css

...
.prose {
    color: #374151;
    max-width: 65ch;
    font-size: 1rem;
    line-height: 1.75
}
...

After making one change in App.svelte, the css outputed looks like this:

...
:global(.prose) {
    color: #374151;
    max-width: 65ch;
    font-size: 1rem;
    line-height: 1.75
}
...

four edits later…

...
:global(:global(:global(:global(.prose)))) {
    color: #374151;
    max-width: 65ch;
    font-size: 1rem;
    line-height: 1.75
}
...

and so on and so forth.

what I found out so far

I found out that uncommenting this in src/utils.ts stops the adding of :global and the css output doesn’t break.

// src/util.ts
...
export function globalStyleSheet(styleSheet: StyleSheet) {
  // turn all styles in stylesheet to global style
  /*
  styleSheet.children.forEach((style) => {
    style.wrapRule((rule: string) => `:global(${rule})`);
  });
  */
...
  return styleSheet;
}

But now the .prose classes are always scoped, which could not be the final solution. I hope you have enough informations to solve the issue and thank you very much for your effort in making windicss and the preprocessors! I highly appreciate that.

Let me know if I can support you in any way.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:4
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
voorjaarcommented, Feb 18, 2021

Will fix this later. The best support for me is to use it and then help me promote it.

1reaction
alexanderniebuhrcommented, Feb 23, 2021

keep in mind that you get svelte scoped hashes if you set globalUtility: false

Read more comments on GitHub >

github_iconTop Results From Across the Web

Configuring global colors and fonts - Webflow Tutorial - LinkedIn
So let's highlight the text, and then start making changes over ... It is possible to add more fonts than the ones that...
Read more >
Lines of Communication – A Typeface History (with Infographic)
Some areas of design change and evolve quickly, but typography has been slower to evolve over the centuries. One emerging technology to watch...
Read more >
How to Use Elementor's Global Colors & Fonts - YouTube
Elementor's global colors & Fonts enable you to change your colors and fonts all in one place, and have it update everywhere you...
Read more >
Global Colors & Fonts: Creating a Design System ... - YouTube
Join Ziv, Elementor Educator 🎓 for a webinar on Creating a Design System with Global Colors and Fonts with Elementor.
Read more >
What Is Typography, and Why Is It Important? [2023 Guide]
Typography is the art of arranging letters and text in a way that makes the copy legible, clear, and visually appealing to the...
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