`require('postcss-plugin')()` vs `require('postcss-plugin')` (without invocation)

Aperta
#225 13 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
35/100
Tipo di issue
Documentazione
Chiarezza
Da chiarire
Stato di attività
Ferma
Stack tecnologico
javascript, tailwindcss
Ambito
documentation

Direzione di ricerca

Start by reading the plugin examples linked from postcss-load-config and autoprefixer, then compare them with the postcss.config.cjs and tailwind.config.cjs usage described here. Clarify the preferred invocation form and document the observable loading behavior so the examples agree.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Hi @ai, thank you for your work on postcss and autoprefixer (and your other packages). We're using them in combination with Vite, Svelte, and Tailwind, and we'd appreciate a clarification on how to specify plugins in postcss.config.cjs.

In this repo (ref), you instruct to require and then invoke a plugin:

module.exports = ({ env }) => ({
  plugins: [
    env === 'production' ? require('postcss-plugin')() : false    // <- with invocation
  ]
})

In autoprefixer (ref), you instruct to require a plugin without invoking it:

module.exports = {
  plugins: [
    require('autoprefixer')                                       // <- without invocation
  ]
}

While investigating performance issues with VS Code, I added a console.log to tailwind.config.cjs and found that:

  • With require('tailwindcss'), Tailwind's config file is loaded several times
  • With require('tailwindcss')(), Tailwind's config file is loaded only once

Question: Could you clarify what is the preferred way to specify plugins?

Thank you for your help!

Lingua principale
JavaScript
Stelle
661
Fork
76
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di postcss/postcss-load-config

Tutte le issue di postcss/postcss-load-config

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.