CSSModule

  • function
steal-css.CSSModule  

CSSModule is a constructor function that is used for loading a .css module. This is mostly useful for CSS plugins that seek to inherit base behavior from steal-css.

new CSSModule(load, loader)

Creates a new instance of CSSModule for the load.

Parameters

  1. load {Object}

    The load object of this module.

  2. loader {Loader}

    The loader loading the module.

new CSSModule(address, source)

Creates a new instance of CSSModule with the given address and source.

Parameters

  1. address {String}

    The address, or URL, of this module.

  2. source {String}Optional

    The source code of this module. This parameter is not required in production [steal.config.env] due to the use of <link> to load the module.

Use

CSSModule encapsulates behaviors for loading CSS modules in both development and production. You instantiate a new object with:

var CSSModule = require("steal-css").CSSModule;

...

var css = new CSSModule(load, loader);

Depending on whether you are trying to inject a <style> tag or a <link> tag use the methods injectStyle or injectLink.

In development mode

Two other useful methods in development are updateURLs and setupLiveReload.

updateURLs rewrites the source code to make the URLs for @import calls relative to the current module.

setupLiveReload takes care of making sure the <style> tag for the module is removed after a new version has been loaded.

Help us improve StealJS by taking our community survey