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
onImport argument includes top-level (importing) file #234
Comments
@MoOx Related: postcss-cli needs to know which file is the parent of the import. postcss-cli formerly relied on the (undocumented) fact that inside Either the parent must be guaranteed to be the first element, or |
X-ref: #233 |
@jmm We added a You can access the messages by filtering var postcss = require('postcss');
postcss([ require('postcss-import') ])
.process(css, { from: 'src/app.css', to: 'app.css' })
.then(function (result) {
// Get list of imports:
var imports = result.messages.filter(message => message.type === 'dependency')
// Write File...
});
{
type: 'dependency',
file: 'ImportedFile.css',
parent: 'FileContainingTheImport.css',
} In the future, I might deprecate or remove |
Hello,
With postcss@5.2.5 and postcss-import@8.1.2 I'm getting the top level file that's passed to postcss in the argument to
onImport
, which is not what I expect. It's documented as:Which I interpet as: the files referenced by
@import
rules.So say I have 2 files like this:
top-level.css
imported.css
/* */
In
onImport
I get an array containing the paths for both files.Is that intentional? If so, can you please document it. And if that's the case, can you commit to it always being the first element in the array?
Thanks!
The text was updated successfully, but these errors were encountered: