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.

Trying out plugin addUtilities noticed a few errors output in console

See original GitHub issue

I created an example sandbox forked from one I stumbled on that you created. https://codesandbox.io/s/cra-tailwind-emotion-starter-4wkeh

My fork adds a plugin to tailwind.config.js then replaces the styling in App.tsx with the new “stack” class that the plugin implements. When loading I see 4 errors reported in the console when you load it. Everything appears to work correctly, just the errors come out and I thought they may indicate a problem internally somewhere.

I am pretty sure I have the styles correct so maybe twin.macro has converted them to real styles before it reaches emotion somewhere ?

So far liking twin.macro, interesting stuff.

This is what my tailwind.config.sj file looks like with the plugin added. The plugin adds stack classes as created and documented by https://every-layout.dev/layouts/stack/

// In CRA, this config file must be inside the src
// so it can be imported by the theme provider

const stackPlugin = ({ addUtilities, theme }) => {
  const spacing = theme('spacing', {})
  const stackCommon = {
    display: 'flex',
    flexDirection: 'column',
    justifyContent: 'flex-start'
  }
  const my_0 = {
    marginTop: 0,
    marginBottom: 0
  }
  const defaultSpacing = spacing['6']
  addStackComponent('.stack', defaultSpacing)
  addRecursiveStackComponent('.rstack', defaultSpacing)
  Object.entries(spacing).forEach(([k, v]) => {
    addStackChildren(`.stack-${k}`, v)
    addStackChildren(`.rstack-${k}`, v, '')
  })

  function addStackComponent(baseName, marginTop) {
    addUtilities({ [baseName]: stackCommon })
    addStackChildren(baseName, marginTop)
  }

  function addRecursiveStackComponent(baseName, marginTop) {
    addUtilities({ [baseName]: stackCommon })
    addStackChildren(baseName, marginTop, '')
  }

  function addStackChildren(baseName, marginTop, child = '>') {
    addUtilities({ [`${baseName} ${child} *`]: my_0 })
    addUtilities({ [`${baseName} ${child} * + *`]: { marginTop } })
  }
}

module.exports = {
  theme: {
    extend: {}
  },
  plugins: [stackPlugin]
}

This is the updated App in App.js

const App = () => (
  <Theme>
    <div
      css={[
        tw`h-screen flex flex-col items-center justify-center`,
        // Combine regular css and Tailwind styles within backticks
        css`
          * {
            ${tw`mt-6`}
          }
          background: linear-gradient(#db00ff, #0047ff);
        `
      ]}
    >
      <div tw="stack">
        <Button isPrimary>Submit</Button>
        <Button isSecondary>Cancel</Button>
        <Button isSmall>Close</Button>
      </div>
      <Logo />
    </div>
  </Theme>
)

These are the errors I see in console. image

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
ben-rogersoncommented, Apr 29, 2020

Haven’t worked this out yet, I’ll take a better look into it after the next Twin version is out.

0reactions
ben-rogersoncommented, Jun 11, 2020

I’ve just pushed a patch for this in 1.4.1 Codepen demo without console errors I’ve had a good look around for more properties with the same issue and we’re looking clear!

Read more comments on GitHub >

github_iconTop Results From Across the Web

plugin shows console errors | WordPress.org
Hi,. We are using Smush Pro plugin for lazy loading. The version of the plugin is 3.12.1. Let us know what you find...
Read more >
Reading error of console using an Eclipse Plugin
I am trying to read the error output from a console using a plugin. This is the piece of code I am running...
Read more >
How to Create Your Own TailwindCSS Plugin - YouTube
In this video, I'll walk through the process of creating your own TailwindCSS plugin. You'll learn how to create a plugin from scratch...
Read more >
Write A Plugin For Tailwind CSS - Egghead.io
Tailwind CSS works with a wide variety of frameworks, such as Next.js, Laravel, and more. You can find out how to do this...
Read more >
Pipeline Job Plugin (workflow-job-plugin) gives empty console ...
When investigating we found an error log that a log file could not be located: ... See attachments for screenshots of the console...
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