egoist / rollup-plugin-postcss

Seamless integration between Rollup and PostCSS.
MIT License
677 stars 217 forks source link

[!] Error: Unexpected character '@' (Note that you need plugins to import files that are not JavaScript) #392

Open sp0033212000 opened 3 years ago

sp0033212000 commented 3 years ago

I got this error when I rollup tailwind module.

My rollup config:

import postcss from "rollup-plugin-postcss";
import typescript from "rollup-plugin-typescript2";

/**
 * @type {import("rollup").RollupOptions}
 */
const config = {
  input: "./src/index.tsx",
  output: [
    { file: "./lib/esm/index.js", format: "esm" },
    { file: "./lib/cjs/index.js", format: "cjs" },
  ],
  plugins: [
    postcss({
      config: { path: "./postcss.config.js" },
      extensions: ["css"],
      minimize: true,
      inject: { insertAt: "top" },
    }),
    typescript({
      tsconfig: "tsconfig.json",
    }),
  ],
  external: ["react", "react-dom"],
};

export default config;
caschbre commented 3 years ago

I started to receive this error message as well. The odd thing is that I have several .svelte files importing css files... but only one is giving me this error so far.

Table.svelte (this works)

<script>
  import './tables.pcss';
</script>

Pager.svelte (this throws the error)

<script>
  import './pagers.pcss';
</script>

In both cases, the (taliwind) css files look like...

@layer components {
  .some-class {}
}