Skip to content
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

PostCSS Error When Exporting Function #10242

Merged
merged 3 commits into from Jan 23, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 30 additions & 0 deletions errors/postcss-function.md
@@ -0,0 +1,30 @@
# Postcss Configuration Is a Function

#### Why This Error Occurred

The project's custom PostCSS configuration exports a function instead of an object.

#### Possible Ways to Fix It

Adjust the custom PostCSS configuration to not export a function.
Instead, return a plain object—if you need environment information, read it from `process.env`.

**Before**

```js
module.exports = ({ env }) => ({
plugins: {
'postcss-plugin': env === 'production' ? {} : false,
},
})
```

**After**

```js
module.exports = {
plugins: {
'postcss-plugin': process.env.NODE_ENV === 'production' ? {} : false,
},
}
```
3 changes: 2 additions & 1 deletion packages/next/build/webpack/config/blocks/css/plugins.ts
Expand Up @@ -118,7 +118,8 @@ export async function getPostCssPlugins(

if (typeof config === 'function') {
throw new Error(
`Your custom PostCSS configuration may not export a function. Please export a plain object instead.`
`Your custom PostCSS configuration may not export a function. Please export a plain object instead.\n` +
'Read more: https://err.sh/next.js/postcss-function'
)
}

Expand Down