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

Parcel 2: PostCSS transform #2157

Closed
devongovett opened this issue Oct 17, 2018 · 3 comments
Closed

Parcel 2: PostCSS transform #2157

devongovett opened this issue Oct 17, 2018 · 3 comments

Comments

@devongovett
Copy link
Member

Create the @parcel/transform-postcss package in packages/transforms/postcss. This package is a Parcel 2 transform plugin for PostCSS. It will be based on the postcss transform inside CSSAsset from Parcel 1, separated into its own package.

The @parcel/transform-postcss package is responsible for the following things:

  • Loading .postcssrc configs
  • Parsing an AST if needed
  • Transforming with PostCSS
  • Generating a string if needed
@jhpratt
Copy link

jhpratt commented Mar 19, 2019

@padmaia Will this allow compilation of entire bundles, rather than each file individually? It's my understanding that's why things like @import don't currently work when using PostCSS.

@padmaia
Copy link
Contributor

padmaia commented Apr 4, 2019

@jhpratt tbh, I've shelved this task while I've been working on some more pressing issues in core. After reading through #1165 we may still want to have the default PostCSS transformer work on a file per file basis so that the performance is optimal by default (parallelization and more granular caching), but it should definitely be possible to configure a custom PostCSS transform that supports your needs. It also might be possible to get the best of both worlds. Perhaps an optimizer plugin that runs over an entire package could replace all of the variables. I'm not sure if that would work or be desirable though 🤷‍♀️

@wbinnssmith wbinnssmith self-assigned this Apr 16, 2019
@mischnic
Copy link
Member

mischnic commented May 6, 2019

Reading #2983, there is a message() function where plugins register dependencies.
This way, a PostCSS plugin that resolves the imports (e.g. (postcss-import](https://github.com/postcss/postcss-import/blob/master/index.js#L199)) can forward the dependency list to Parcel for the watcher/HMR.

ai pushed a commit to postcss/postcss that referenced this issue Jul 17, 2019
* Fix README.md claim of "perfect" Parcel support

Update `README.md` to not tout Parcel's implementation as "perfect". There are [the several issues in Version 1](https://github.com/parcel-bundler/parcel/labels/CSS%20Preprocessing). And [Version 2](https://github.com/parcel-bundler/parcel/projects/5) is not out yet to [possibly fix the issues via [issue #2157](parcel-bundler/parcel#2157).

I am amenable to any alteration of this edit. Perhaps, the change should be _only_ to remove the word "perfect". But, Parcel's implementation has been flawed for a long time.

_I provide the extra information, in hopes of saving someone else from believing Parcel will manage PostCSS for them. Three times over this and the past years, I have crawled out of the maze of Parcel & PostCSS rabbit holes to decide that it is _still_ better for a project to process with PostCSS directly, independently of Parcel._

* Fix README.md grammar in previous edit

I fixed grammatical errors that I made in my previous edit of the README.md.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants