Skip to content

Rollup plugin for loading constructable style sheets

License

Notifications You must be signed in to change notification settings

Alorel/rollup-plugin-constructable-css

Repository files navigation

rollup-plugin-constructable-css

A rollup plugin for loading css files as CSSStyleSheets.

Core Coverage Status Language grade: JavaScript


Installation

Add the registry to .npmrc:

@alorel:registry=https://npm.pkg.github.com

Then install it:

npm install @alorel/rollup-plugin-constructable-css

Options

All options are standard rollup plugin options.

interface ConstructableCssRollupPluginOpts {
  exclude?: FilterPattern;

  include: FilterPattern;

  /** @default false */
  preferConst?: boolean;

  /** @default true */
  sourceMap?: boolean;
}

Usage

import {constructableCssRollupPlugin} from '@alorel/rollup-plugin-constructable-css';

export default {
  // ...
  plugins: [
    constructableCssRollupPlugin({
      include: /\.constructed\.css/
    })
  ]
}

Transformation

Input

body{color:red};

Output

var stylesheet = new CSSStyleSheet();
stylesheet.replaceSync("body{color:red};");

export default stylesheet;