2023-07-05 15:11:16 +02:00
|
|
|
---
|
|
|
|
title: PostCSS Configuration Is a Function
|
|
|
|
---
|
2020-01-23 21:39:50 +01:00
|
|
|
|
2023-07-05 15:11:16 +02:00
|
|
|
## Why This Error Occurred
|
2020-01-23 21:39:50 +01:00
|
|
|
|
|
|
|
The project's custom PostCSS configuration exports a function instead of an object.
|
|
|
|
|
2023-07-05 15:11:16 +02:00
|
|
|
## Possible Ways to Fix It
|
2020-01-23 21:39:50 +01:00
|
|
|
|
2023-07-05 15:11:16 +02:00
|
|
|
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`.
|
2020-01-23 21:39:50 +01:00
|
|
|
|
|
|
|
**Before**
|
|
|
|
|
2023-07-05 15:11:16 +02:00
|
|
|
```js filename="postcss.config.js"
|
2020-01-23 21:39:50 +01:00
|
|
|
module.exports = ({ env }) => ({
|
|
|
|
plugins: {
|
|
|
|
'postcss-plugin': env === 'production' ? {} : false,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
```
|
|
|
|
|
|
|
|
**After**
|
|
|
|
|
2023-07-05 15:11:16 +02:00
|
|
|
```js filename="postcss.config.js"
|
2020-01-23 21:39:50 +01:00
|
|
|
module.exports = {
|
|
|
|
plugins: {
|
|
|
|
'postcss-plugin': process.env.NODE_ENV === 'production' ? {} : false,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
```
|