-
Notifications
You must be signed in to change notification settings - Fork 8
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
How to use it with next-compose-plugins and next-sass? #9
Comments
You should be able to use it like this : // next.config.js
const withPlugins = require('next-compose-plugins');
const purgecss = require('next-purgecss');
const sass = require('@zeit/next-sass');
const nextConfig = {
// your next.js configuration
};
const plugins = [
[sass, {
// purgecss config
}],
[purgecss, {
// sass config
}]
];
module.exports = withPlugins(plugins, nextConfig); Let me know if it works for you 🙂 |
Does it work with SASS Modules ? |
Can you share a reproduction? The order of the plugins might be the issue. |
Sure, here's my next.config.js:
|
Thanks! I'm not really familiar with next-compose-plugins, but could you try to put purgecss first in the list ? Like this:
|
If I do this, node throws me this error:
|
@nagman Awesome! I have published a new version of the package ( |
Thanks @lucleray! |
Oh, that's unexpected. It may be the underlying packages : https://github.com/FullHuman/purgecss I don't really have control over those. I found an open issue that seems to be related to yours here : FullHuman/purgecss#163 |
@dr-martin I don't understand what you mean by
Does it work? Or does it fail without any error? If it works for you, I'd like to see your |
@dr-martin & @nagman Did Either of you manage to solve this. I have the same problem. |
@skywickenden Nope. I've given up with this. |
Had same error, worked for me only without any of sass config options (and next-css can be omitted). Like:
|
I am having the same issue. Anyone solved it? |
Anyone still facing the problem of using purgecss with css module, use @fullhuman/postcss-purgecss with the postcss config, see their site for usage documentation. The problem with this plugin is it uses purgecss webpack loader and it runs before the hashed CSS class is generated. Hence it removes all the CSS. With the postcss purge it runs on the final CSS that gets generated. |
@rinkusam12 Thank you for your tips but @fullhuman/postcss-purgecss still won't work since Next.js generated HTML dynamically so can't set the content. Please let me know if you have a better way to set the content. Thank you.
|
@bhkim526 Its not working because you are targetting the wrong file. replace |
Is anybody able to fix the issue? I am stuck as well. I tried all the mentioned solutions but none of them working as expected. |
i have to use purgecss with compose-plugins only i tried all of the config that is mention above but it's not working my css chunk is showing 100% of code is unused |
I had the same problem and ended up in a solution without using any next plugins at all, by only using the postcss config. Just let the next.config.js file untouched and create a new file module.exports = {
plugins: [
"postcss-flexbugs-fixes",
[
'@fullhuman/postcss-purgecss',
{
content: [
'./pages/**/*.{js,jsx,ts,tsx}',
'./pages/**/**/*.{js,jsx,ts,tsx}',
'./pages/**/**/**/*.{js,jsx,ts,tsx}',
'./pages/**/**/**/**/*.{js,jsx,ts,tsx}',
'./components/**/*.{js,jsx,ts,tsx}',
'./components/**/**/*.{js,jsx,ts,tsx}',
'./components/**/**/**/*.{js,jsx,ts,tsx}',
'./components/**/**/**/**/*.{js,jsx,ts,tsx}',
]
}
],
[
"postcss-preset-env",
{
"autoprefixer": {
"flexbox": "no-2009"
},
"stage": 3,
"features": {
"custom-properties": false
}
}
],
]
}; |
react slick slider and phone-input2 styles are removing which is used in my components |
its not working mate :( |
I did similar to @tilman . I copied what nextjs says to start with into I included my additional Unfortunately, this solution doesn't use the
|
Has anyone solved the problem (with cssModules)? |
No description provided.
The text was updated successfully, but these errors were encountered: