Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested css in template results in skipping template #7

Open
Nume opened this issue Jan 3, 2023 · 6 comments
Open

Nested css in template results in skipping template #7

Nume opened this issue Jan 3, 2023 · 6 comments

Comments

@Nume
Copy link

Nume commented Jan 3, 2023

Nesting styled-component css inside any styled-component template literal results in the template being skipped.

Example:

import styled, { css } from "styled-components"

const Foo = styled.div`
  ${css`
    color: hotpink;
  `}
`

Output: [postcss (styled-components)] Skipping template (file: ...) as it included either invalid syntax or complex expressions the plugin could not interpret. Consider using a "// postcss-styled-components-disable-next-line" comment to disable this message

@43081j
Copy link
Owner

43081j commented Jan 3, 2023

good catch!

do you happen to know if it only happens when the whole thing is a sub-template?

e.g. does this also fall over?

const Foo = styled.div`
  padding: 2rem;
  ${css`
    color: hotpink;
  `}
`;

ill write some tests today for it if i can and see if i can fix it anyhow 👍

@Nume
Copy link
Author

Nume commented Jan 3, 2023

Any template with nested css is being skipped. Does not seem to matter what other properties is added.

@43081j
Copy link
Owner

43081j commented Jan 3, 2023

interesting, will take a look.

thanks for confirming that for me

@Nume
Copy link
Author

Nume commented Jan 3, 2023

After further testing it seems like its actually if css is the first property which triggers the skipping (when i was testing i was adding properties after the css)

So your example above is not actually trigger the skipping, but it is instead triggering Expected empty line before comment comment-empty-line-before rule (which does not seem correct either)

@43081j
Copy link
Owner

43081j commented Jan 3, 2023

thats good to know, i imagine it'll be a bug in how we generate the source CSS for postcss

ill take a look today 👍

@43081j
Copy link
Owner

43081j commented Jan 3, 2023

i've opened 43081j/postcss-js-core#6 which will fix this once it is completed.

will leave this open until a new version of the styled-components syntax is published with the fixed core too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants