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.

Force twind shim to render sheet with all classes even if not present in the dom

See original GitHub issue

Hi, I’m building a utility that will allow you to use twind to render multiple different versions of the style sheet (I’m doing so in an iframe as I have found that twind is pretty “global” in nature - yes, I’ve read all of the examples about .reset()). What I’m doing right now with rendering twind in an iframe to force isolation works fine. I render the domSheet() in an iframe and report back the generated stylesheet to the main document. This allows me to non-destructively/statelessly try out different configs (almost like hot reloading). The problem is that the generated stylesheet will only render classes that are actually used in the document. Is there a way to tell the setup() to render all classes even if they’re not used yet?

I have also tried using the “non shim” version of the module to no avail. Here’s my example:

            import *  as twindShim from 'https://cdn.skypack.dev/twind/shim';
            twindShim.setup({
              preflight: true, // do not include base style reset (default: use tailwind preflight)
              mode: 'warn', // throw errors for invalid rules (default: warn)
              hash: false, // hash all generated class names (default: false)
              theme: {
                colors: MY_COLORS
              }, // define custom theme values (default: tailwind theme)
              darkMode: 'class', // use a different dark mode strategy (default: 'media')
              sheet: domSheet()
            });
            window.parent.postMessage(
              {
                messageType: "styleData",
                styleInnerHTML: document.querySelectorAll('style')[0].innerHTML
              },
              "*"
            );

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:66 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
jordwalkecommented, Mar 23, 2021

I’ll give it a try! Thanks for the help!

2reactions
sastancommented, Mar 23, 2021

@danielweck Please do not forget about @twind/cli. Our tool to generate a CSS file - works just like the new tailwindcss jit, but without postcss

Read more comments on GitHub >

github_iconTop Results From Across the Web

Configuration and Theming - Twind
The setup function is a named export of the twind module and accepts a configuration object as an argument. TIP. The setup function...
Read more >
isorender/dom-shims.js - Documentation
* Node.js polyfill for rendering Panel components without a browser. * Makes the following objects globally available: * Comment, document, Document, Element, ...
Read more >
How to Build A React TS Tailwind Design System
In the Twin example repo, there was no Styled Components + Storybook example, so I configured what seemed to make sense. Then I...
Read more >
Understanding Repaint and Reflow in JavaScript | The Startup
So, let's have a high-level view of how a browser works! ... The render tree is sort of like the DOM tree but...
Read more >
Building Production-Ready CSS Grid Layouts Today
If you agree with this (and you should), there is no reason you can't ... All we have to do is make it...
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