Home Reference Source
import {ProjextRollupCSSPlugin} from 'projext-plugin-rollup/src/plugins/css/index.js'
public class | source

ProjextRollupCSSPlugin

This is a Rollup plugin for handling CSS stylesheets: Move them into a separated bundle, inject them when the browser loads the app and transform them into strings so they can be used on Node.

Constructor Summary

Public Constructor
public

Member Summary

Public Members
public

The filter to decide which files will be processed and which won't.

public

The name of the plugin instance.

Method Summary

Public Methods
public

Gets the plugin options

public

This gets called when Rollup starts the bundling process.

public

Processes a file in order to determine whether it should export an empty string (in case the styles are being moved to a bundle), export the code and/or add extra named exports.

public

This gets called by Rollup when the bundle is being generated.

Public Constructors

public constructor(options: ProjextRollupCSSPluginOptions, name: string) source

Params:

NameTypeAttributeDescription
options ProjextRollupCSSPluginOptions
  • optional
  • default: {}

The options to customize the plugin behaviour.

name string
  • optional
  • default: 'projext-rollup-plugin-css'

The name of the plugin's instance.

Public Members

public filter: RollupFilter source

The filter to decide which files will be processed and which won't.

public name: string source

The name of the plugin instance.

Public Methods

public getOptions(): ProjextRollupCSSPluginOptions source

Gets the plugin options

public intro(): string source

This gets called when Rollup starts the bundling process. If the insert option was set to true, this method will return the custom function the bundle will use to inject the styles on the <head />.

Return:

string (nullable: true)

public transform(code: string, filepath: string): Promise<RollupFileDefinition, Error> source

Processes a file in order to determine whether it should export an empty string (in case the styles are being moved to a bundle), export the code and/or add extra named exports.

Params:

NameTypeAttributeDescription
code string

The contents of the file that it's being processed.

filepath string

The path of the file that it's being processed.

Return:

Promise<RollupFileDefinition, Error> (nullable: true)

public writeBundle() source

This gets called by Rollup when the bundle is being generated. It takes care, if needed, to create the stylesheet bundle.