postcss / postcss-mixins

PostCSS plugin for mixins
MIT License
466 stars 47 forks source link

TailwindCSS support - Error: No parent could be found #118

Closed jfdelarosa closed 3 years ago

jfdelarosa commented 3 years ago

I'm trying to use this plugin along with postcss-nested as a replacement for SASS, sadly, this plugin throws an error when you try to use TailwindCSS's @apply inside a mixin:

This works:

@define-mixin alert {
  background: red;
}

This doesn't work:

@define-mixin alert {
  @apply bg-red-500;
}

This is the error it throws:

ERROR in ./src/components/Alert/alert.css (./node_modules/css-loader/dist/cjs.js!./node_modules/@storybook/addon-postcss/node_modules/postcss-loader/dist/cjs.js??ref--9-2!./src/components/Alert/alert.css)
Module build failed (from ./node_modules/@storybook/addon-postcss/node_modules/postcss-loader/dist/cjs.js):
Error: No parent could be found
    at ***/src/components/Alert/alert.css:2:3
    at findParent (***/node_modules/tailwindcss/lib/lib/substituteClassApplyAtRules.js:218:9)
    at ***/node_modules/tailwindcss/lib/lib/substituteClassApplyAtRules.js:228:33
    at ***/node_modules/postcss/lib/container.js:151:16
    at ***/node_modules/postcss/lib/container.js:74:18
    at AtRule.each (***/node_modules/postcss/lib/container.js:60:16)
    at AtRule.walk (***/node_modules/postcss/lib/container.js:71:17)
    at ***/node_modules/postcss/lib/container.js:79:24
    at Root.each (***/node_modules/postcss/lib/container.js:60:16)
    at Root.walk (***/node_modules/postcss/lib/container.js:71:17)
    at Root.walkAtRules (***/node_modules/postcss/lib/container.js:149:17)
    at processApplyAtRules (***/node_modules/tailwindcss/lib/lib/substituteClassApplyAtRules.js:225:9)
    at ***/node_modules/tailwindcss/lib/lib/substituteClassApplyAtRules.js:334:14
    at async LazyResult.runAsync (***/node_modules/postcss/lib/lazy-result.js:358:11)
    at async LazyResult.runAsync (***/node_modules/postcss/lib/lazy-result.js:358:11)
    at async Object.loader (***/node_modules/@storybook/addon-postcss/node_modules/postcss-loader/dist/index.js:95:14)

Has anyone had a similar problem?

ai commented 3 years ago

Most of stack trace came from Tailwind. Open an issue there.

william-will-angi commented 7 months ago

@jfdelarosa any chance you figured this out?