egoist / egoist/rollup-plugin-postcss

Error: Unexpected token (Note that you need plugins to import files that are not JavaScript) src/main.css

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

Description

- Rollup Version: 2.26.3
- Operating System (or Browser): Chrome
- Node Version (if applicable): v12.16.1
- Link to reproduction (IMPORTANT, read below):

### Expected Behavior

```
-dist
--my-faceapi-js-lib.cjs.js
--my-faceapi-js-lib.esm.js
--my-faceapi-js-lib.umd.js
--my-faceapi-js-lib.css

```
### Actual Behavior

_I'm writing JS library using [rollup-starter-lib](https://github.com/rollup/rollup-starter-lib) as base of my JS library_

_Before update rollup version, I feel like it's .css file not creating due to tree shaking because of css not used in this JS library itself._

**Then, I update rollup version to `2.26.3` from `1.29.0` now it's generate only following two files along with below error. It's seams there is an issue with rollup or postCss plugin.**

```
--my-faceapi-js-lib.umd.js
--my-faceapi-js-lib.css
```
>
> [!] Error: Unexpected token (Note that you need plugins to import files that are not JavaScript)
> src/main.css (1:0)
>

rollup.config.js
```
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import pkg from './package.json';
import path from 'path'
import postcss from 'rollup-plugin-postcss'

export default [
{
input: 'src/main.js',
output: {
name: 'my-faceapi-js-lib',
file: pkg.browser,
format: 'umd'
},
plugins: [
postcss({
minimize: true,
extensions: ['.css'],
extract: path.resolve('dist/my-faceapi-js-lib.css'),
}),
resolve(), // so Rollup can find `ms`
commonjs() // so Rollup can convert `ms` to an ES module
]
},
{
input: 'src/main.js',
external: ['ms'],
output: [
{ file: pkg.main, format: 'cjs' },
{ file: pkg.module, format: 'es' }
]
}
];
```
main.js

```
import * as faceapi from "face-api.js";
...
import './main.css';
...
...
```
Basically there is not usage of `main.css` within JS library it self. but it's necessary when integrate this library.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.