-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
using function for build.postcss config option #7015
Comments
Some details for a scenario like this:
which would solve all our problems ;) our postcss file looks now somethign like @suits-at has mentioned, adds all the "postcss" config that nuxt adds automatically manually in there again (which is kinda worring us..) and finally adds purgecss plugin only in case it is our "main" css file. this works great, we have dropped our build time by more than the half :-) But, again... the postcss.config.js "method" is deprecated, so we are looking for alternatives, and it would also be great to just "modify" the postcss config for each processed file beforehand, so that nuxt could still build the config, other modules could extend it etc. and then a hook just "modifies" it to your own need. this hook should get a copy of the "original" config object and the postcss ctx, and returns a modified version of the config (or just the same...) pinging @manniL Thanks |
bump |
@simllll You should be able to pass a function to the config of each plugin which lets you access the loader context - see https://codesandbox.io/s/wizardly-cdn-ts7sq?file=/pages/index.vue |
@danielroe it's not about passing a function to the plugin, it's about passing a function to postcss-loader directly. see https://webpack.js.org/loaders/postcss-loader/#postcssoptions |
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:
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.
The text was updated successfully, but these errors were encountered: