Skip to content

fix: check if postcss-import is already included in plugins#2440

Closed
piecyk wants to merge 1 commit intovitejs:mainfrom
piecyk:fix/css/check-for-import-plugin
Closed

fix: check if postcss-import is already included in plugins#2440
piecyk wants to merge 1 commit intovitejs:mainfrom
piecyk:fix/css/check-for-import-plugin

Conversation

@piecyk
Copy link

@piecyk piecyk commented Mar 9, 2021

Hi, in cases when there is already defined postcss-import in config plugins let's not add default one from vite

@underfin
Copy link
Member

underfin commented Mar 9, 2021

The postcss-import is need process some case like alias, your provider version is lost it. Look like give users some warning is better?

@piecyk
Copy link
Author

piecyk commented Mar 9, 2021

The postcss-import is need process some case like alias, your provider version is lost it. Look like give users some warning is better?

hmm if someone has a custom plugin for resolving @import then imho he would like to opt out from default.

For example, importing json files that would be converted to custom properties @import './lib/css/colors.json'

require('postcss-import')({
  path: ['src'],
  load: loadContentWithJson,
}),

@yyx990803
Copy link
Member

I think it's better to

  1. Warn that Vite already includes postcss-import if user provides their own
  2. Add css.postcssImportOptions which can be merged into Vite's internal postcss-import options (and mention this in the warning message as well).

@patak-cat patak-cat added p2-nice-to-have Not breaking anything but nice to have (priority) feat: css labels Mar 23, 2021
@patak-cat
Copy link
Member

Hey @piecyk, would you like to keep this PR open to work in the future point on the suggested changes by Evan? We could create an enhancement issue if not tracking this improvement.

@piecyk
Copy link
Author

piecyk commented Mar 23, 2021

@matias-capeletto Yes.

@yyx990803 Thanks for replay 👍 I think having it other way around would be more flexible, it's more advance case. Would pass the resolve function to postcss config. Similar as in #2436 ( also waiting for review 👋 ) file, and push the responsibility of passing it to postcss-import to user.

Having separate postcss.config and then need to specify in vite config postcssImportOptions would look bit off.

If you still think that postcssImportOptions is the way to go, ping me and I will update the PR.

@piecyk
Copy link
Author

piecyk commented Mar 31, 2021

ping @yyx990803

@patak-cat patak-cat requested a review from yyx990803 March 31, 2021 06:30
@Shinigami92
Copy link
Member

Hey @piecyk, we are using GitHub's review requests when we need Evan's input so he can look at all the issues and PR that require his attention when he is focusing on Vite. There is no need to explicitly ping him with an extra message.

@Shinigami92
Copy link
Member

@piecyk 👋 I currently just wanted to review/reproduce your PR and check if everything is working
But sadly you don't provide a repro right now 🙁
Could you add a repo or at least instructions what to setup for a repro?

@piecyk
Copy link
Author

piecyk commented Apr 1, 2021

Hey @piecyk, we are using GitHub's review requests when we need Evan's input so he can look at all the issues and PR that require his attention when he is focusing on Vite. There is no need to explicitly ping him with an extra message.

Ok, fyi requests was added after i did the ping 🤷‍♂️

@piecyk
Copy link
Author

piecyk commented Apr 1, 2021

@piecyk 👋 I currently just wanted to review/reproduce your PR and check if everything is working
But sadly you don't provide a repro right now 🙁
Could you add a repo or at least instructions what to setup for a repro?

hmm you can checkout branch from this PR https://github.com/piecyk/vite/tree/fix/css/check-for-import-plugin and use the css playground. For example adding the postcss-import to https://github.com/piecyk/vite/blob/fix/css/check-for-import-plugin/packages/playground/css/postcss.config.js

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

Labels

feat: css p2-nice-to-have Not breaking anything but nice to have (priority)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants