egoist / egoist/rollup-plugin-postcss

TypeError: Invalid PostCSS Plugin found at: plugins[0]

Open
#360 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
689
Forks
210
PR merge metrics
No merged PRs in 30d

Description

```
rollup-plugin-postcss@4.0.0
rollup@1.32.1
next@10.0.7
```

**postcss.config.js**
```js
module.exports = {
plugins: ['tailwindcss', 'postcss-preset-env'],
};
```
**rollup.config.js**
```js
import peerDepsExternal from "rollup-plugin-peer-deps-external";
import commonjs from "@rollup/plugin-commonjs";
import typescript from "rollup-plugin-typescript2";
import postcss from "rollup-plugin-postcss";
import copy from "rollup-plugin-copy";
import image from "@rollup/plugin-image";
import resolve from 'rollup-plugin-node-resolve';

export default {
input: "src/components/index.ts",
output: [
{
dir: "build",
format: "cjs",
sourcemap: false
},
{
dir: "build/esm",
format: "esm",
sourcemap: false
}
],
preserveModules: true,
plugins: [
peerDepsExternal(),
commonjs(),
image(),
resolve({ browser: true }),
typescript({
useTsconfigDeclarationDir: true,
"jsx": "react",
}),
postcss({ modules: true, inject: false, extract: true, config: { path: './postcss.config.js' } }),
copy({
targets: [
{
src: "src/styles/_variables.scss",
dest: "build",
rename: "variables.scss"
},
{
src: "src/components/package.json",
dest: "build",
rename: "package.json"
}
]
})
]
};
```

**ERROR**
```
[!] (plugin postcss) TypeError: Invalid PostCSS Plugin found at: plugins[0]

(@/***/postcss.config.js)
src/components/Badge/badgeComponent.module.scss
TypeError: Invalid PostCSS Plugin found at: plugins[0]
```

To workaround this I just add `require` like so
```js
module.exports = {
plugins: [require('tailwindcss'), require('postcss-preset-env')],
};
```
But this is not working for the nextjs - [more info here](https://github.com/vercel/next.js/blob/master/errors/postcss-shape.md)

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with postcss.config.js and rollup.config.js, then reproduce the reported error around rollup-plugin-postcss with the listed versions. Done means the shown configuration no longer raises the invalid plugin error, with the stated Next.js compatibility concern addressed.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, next.js, tailwindcss
Domain
build-system, frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.