facebook / docusaurus

Easy to maintain open source documentation websites.
https://docusaurus.io
MIT License
55.83k stars 8.37k forks source link

Allow an ergonomic way to filter plugins between dev & prod. #3663

Closed phated closed 3 years ago

phated commented 3 years ago

🚀 Feature

Allow an ergonomic way to filter plugins between dev & prod. We were asked to open an issue about this in Discord - ref https://github.com/gulpjs/gulpjs.github.io/issues/123#issuecomment-718696325

Have you read the Contributing Guidelines on issues?

Yes.

Motivation

For gulp's website, we want to have a series of plugins that are only applied at production-build time (analytics, gtag, sitemap, etc).

We are currenly doing it with this code, on an old 2-alpha version:

plugins: [
    isProd && ['@docusaurus/plugin-google-analytics', {}],
    isProd && ['@docusaurus/plugin-google-gtag', {}],
    isProd && ['@docusaurus/plugin-sitemap', {}],
]

This became invalid in a more recent alpha version that we are upgrading into because those resolve to false in development.

Pitch

I think it is fairly common that people will want to have some plugins they don't want active during development (e.g. carbon-ads plugin) and they will want a concise way to filter those out.

slorber commented 3 years ago

thanks, make sense ;)

as I said on discord, some of those plugins already enable only in prod, but yeah having this conditional feature will be useful