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

Đang mở
#225 13 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
35/100
Loại issue
Tài liệu
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Đình trệ
Công nghệ
javascript, tailwindcss
Lĩnh vực
documentation

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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!

Ngôn ngữ chính
JavaScript
Star
661
Fork
76
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của postcss/postcss-load-config

Tất cả issue của postcss/postcss-load-config

Issue tương tự

Thêm issue về JavaScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.