PostCSS configuration examples often show common js code with module.exports
.
module.exports = {
plugins: [
require('autoprefixer')
]
}
If your project is a JS module, with "type": "module"
in package.json, it will complain that the config file is not a JS module.
To fix it, you can change the file extension to .cjs, meaning it is a common JS script so it won't try to run as a module.
Or you can convert it to module syntax with export default {}
.
import autoprefixer from "autoprefixer";
export default {
plugins: [
autoprefixer,
]
}
Classes
Resources