Skip to content

Scoped Styling for Tailwind in Embedded Widgets #11922

Answered by doneumark
doneumark asked this question in Help
Discussion options

You must be logged in to vote

I think I got it :)

"postcss-prefix-selector": {
      prefix: "#my-container-id",
      includeFiles: ["globals.css"],
      transform: function (prefix, selector, prefixedSelector) {
        if (selector.match(/^(html|body)/)) {
          return selector.replace(/^([^\s]*)/, `$1 ${prefix}`);
          // } else if (selector.match(/^\.(some-class-we-dont-want-to-scope|some-other-class-we-dont-want-to-scope)/)) {
          //   return selector;
        } else {
          return prefixedSelector;
        }
      },
    },

inside plugins in "postcss.config.js"

Replies: 3 comments 4 replies

Comment options

You must be logged in to vote
1 reply
@wongjn
Comment options

Comment options

You must be logged in to vote
3 replies
@wongjn
Comment options

@doneumark
Comment options

@wongjn
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by doneumark
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants