CSSModule
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
-
load
{Object}
The load object of this module.
-
loader
{Loader}
The loader loading the module.
new CSSModule(address, source)
Creates a new instance of CSSModule with the given address and source.
Parameters
-
address
{String}
The address, or URL, of this module.
-
source
{String}
OptionalThe 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:
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.