yuyicman
yuyicman

Reputation: 95

Why Rollup doesn't generate "import css" line to the bundled file?

does anyone know why Rollup doesn't generate import css line to the output js file? Here is my rollup config:

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

export default {
  input: "src/index.ts",
  output: {
    file: "dist/index.js",
    format: "es"
  },
  plugins: [
    typescript({
      typescript: require("typescript")
    }),
    postcss({
      extract: true,
      extensions: [".less"],
      use: [["less", { javascriptEnabled: true }]]
    })
  ]
};

src/index.ts:

import "./index.less";

What I expected result is as following:

`require("./index.css");`

But the bundled result is empty.

Upvotes: 4

Views: 3103

Answers (1)

Skuggomann
Skuggomann

Reputation: 9

extract: true

This option moves the css to a seperate .css file instead of including it in the .js file.

Upvotes: 0

Related Questions