-
Notifications
You must be signed in to change notification settings - Fork 4.5k
PostCSS warning for custom utility used with before:/after: #13591
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
Comments
This could be related to the tailwindcss/src/corePlugins.js Line 64 in f1f419a
The const importer = declaration.source?.input.file
if (!importer) {
opts.logger.warnOnce(
'\nA PostCSS plugin did not pass the `from` option to `postcss.parse`. ' + As per the 2.4 of the PostCSS Plugin Guidelines:
So perhaps we could clone a declaration inside the variant plugin, instead of creating a new one from scratch? But why only with your own declared utilities? The plot thickens! It seems when we are generating the CSS: tailwindcss/src/lib/expandTailwindAtRules.js Lines 244 to 246 in f1f419a
We skip setting tailwindcss/src/util/cloneNodes.js Lines 22 to 25 in f1f419a
And for tailwindcss/src/lib/setupContextUtils.js Lines 724 to 726 in f1f419a
Thus, for plugin-defined utilities, we don't have to worry about retaining So what would be the best way to solve this? Push the onus on to the plugins that use the PostCSS API to ensure they create appropriate Example test for this:test('source maps for layer rules with injected nodes from plugins', async () => {
let config = {
content: [{ raw: `foo:bar` }],
plugins: [
function ({ addVariant }) {
addVariant('foo', ({ container }) => {
container.walkRules((rule) => {
rule.prepend(postcss.decl({ prop: 'foo', value: 'baz' }))
})
})
},
],
}
let input = postcss.parse(
css`
@tailwind utilities;
@layer utilities {
.bar {
background-color: red;
}
}
`,
{ from: 'input.css', map: { prev: map } }
)
let result = await run(input, config)
let { sources, annotations } = parseSourceMaps(result)
// All CSS generated by Tailwind CSS should be annotated with source maps
// And always be able to point to the original source file
expect(sources).not.toContain('<no source>')
}) |
Found this, because I just got the same error when using a custom utility with EDIT: using |
Got the same error message, removed all Turns out the following lines introduced the message:
I think, rewriting a reserved name is not allowed. I have no idea why |
I'm experiencing this same error message too. I have tracked it down to using
Moving it out side of the |
I too tracked down a single item that caused the "A PostCSS plugin did not pass the
As above, taking it out of the |
Same issue. @layer utilities {
.flag-right {
clip-path: path(
'M-1 0h.768a6 6 0 0 1 4.797 2.396l18.796 25.018a8 8 0 0 1-.038 9.66L4.566 61.64A6 6 0 0 1-.203 64H-1V0Z'
);
}
.flag-left {
clip-path: path(
'M3 0h17v64H3.055a3 3 0 0 1-2.44-4.744l15.997-22.383a8 8 0 0 0 .035-9.254L.547 4.726A3 3 0 0 1 3 0Z'
);
}
} And I use |
The next release will have support for source maps in development — which should get rid of this warning/error. |
What version of Tailwind CSS are you using?
3.4.3
What build tool (or framework if it abstracts the build tool) are you using?
Vite
What version of Node.js are you using?
v21.7.3
What browser are you using?
Chrome
What operating system are you using?
macOS
Reproduction URL
https://stackblitz.com/edit/vitest-dev-vitest-cp1r2y
Describe your issue
There's a PostCSS warning in the console:
It starts when you define your own CSS utility and use it with the
before:
orafter:
.Example:
css file:
Usage:
The text was updated successfully, but these errors were encountered: