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

Add PostCSS dependency message support #2983

Closed
ai opened this issue May 6, 2019 · 2 comments · Fixed by #3980
Closed

Add PostCSS dependency message support #2983

ai opened this issue May 6, 2019 · 2 comments · Fixed by #3980

Comments

@ai
Copy link

ai commented May 6, 2019

🙋 feature request

PostCSS ecosystem has an unofficial API: plugins add dependency message for every resource used by this plugin:

let css = `
.icon {
  background: inline-svg(./logo.svg)
}
`

const result = await postcss([inlineSVG]).process(css)
result.messages() // => [{ type: 'dependency', file: '/Dev/project/logo.svg' }]

postcss-loader and other PostCSS runners use this message to start watching for used resources.

Let’s add it to Parcel too.

🤔 Expected Behavior

Parcel will watch for resources from dependency messages and re-build bundle on resource’s changes.

😯 Current Behavior

Seems like Parcel doesn’t use it.

💁 Possible Solution

Just check result.messages().filter(i => i.type === 'dependency') after PostCSS call.

🔦 Context

Lack of this feature was found in Tailwind community since the lack of dependency support creates unexpected behavior:

https://twitter.com/kevdotbadger/status/1125415276097544193

Here is our small talk with @adamwathan

https://twitter.com/adamwathan/status/1125417346154106881

💻 Examples

Here is a small project to test the feature:

https://github.com/adamwathan/parcel-postcss-dependency-message

@ai
Copy link
Author

ai commented May 6, 2019

@devongovett if you like this feature, but have no time to implement it, I can ask my friends to help.

@mischnic
Copy link
Member

mischnic commented May 6, 2019

Parcel will watch for resources from dependency messages and re-build bundle on resource’s changes.

This solves an issue supporting postcss import plugins would have #1165 (comment)

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

Successfully merging a pull request may close this issue.

3 participants