-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
using function for build.postcss config option #7015
Description
What problem does this feature solve?
I am using a function inside of a .postcssrc.js config file, to react to the current processed file. Doing this, I am able to use purgeCss only on one specific file.
So basically I am doing this:
module.exports = ({ file }) => {
const doPurgeCSS = file.basename === 'example.scss';
if (doPurgeCSS) {
plugins['@fullhuman/postcss-purgecss'] = {
someOtherOptions
};
}
return {
plugins
};
};
I know that I would lose the default nuxt config using this code, but for the reproduction I ommited this part due to simplicity.
The docs (https://nuxtjs.org/faq/postcss-plugins/) say using a config file is already deprecated and won't work in nuxt 3. But as far as I understand, you can not pass a function to the build.postcss option right now and therefore there is no other way to do this at the moment.
What does the proposed changes look like?
Allow build.postcss to use a function, and expose CTX to it, just like postcss-loader does (https://github.com/postcss/postcss-loader#context-ctx) to make the config file dynamic.