我想在我的 NextJS 项目中使用 purgeCss。在文档中它说我应该将我的更改next.config.js
为:
module.exports = withCss(withPurgeCss())
但是我在哪里设置我的当前配置?
module.exports = {
distDir: '../.next',
webpack: config => {
const env = Object.keys(process.env).reduce((acc, curr) => {
acc[`process.env.${curr}`] = JSON.stringify(process.env[curr]);
return acc;
}, {});
config.resolve.modules.push(path.resolve('./'));
config.plugins.push(new webpack.DefinePlugin(env));
return config;
},
};
我的 postcss.config.js:
module.exports = {
"plugins": [
"postcss-flexbugs-fixes",
[
"postcss-preset-env",
{
"autoprefixer": {
"flexbox": "no-2009"
},
"stage": 3,
"features": {
"custom-properties": false
}
}
],
[
'@fullhuman/postcss-purgecss',
{
content: [
'./pages/**/*.{js,jsx,ts,tsx}',
'./components/**/*.{js,jsx,ts,tsx}'
],
defaultExtractor: content => content.match(/[\w-/:]+(?<!:)/g) || [],
safelist: ["html", "body"]
}
],
]
}