Enables CSS as a first-class module-type. It allows you to require, transform and emit CSS with the same power that you have for JavaScript.
Under the hood, this parses CSS into AST using PostCSS.
This plugin may be required for other plugins to function correctly.
Make sure you have installed the plugin as a dependency in your project:
$ npm install --save-dev interlock-css
Then, include it in your config:
const css = require("interlock-css");
module.exports = {
// ... config options
plugins: [
css({
// ... your options here
})
// .. other plugins
]
};mode- One of three strings:bundle,insert, orobject. Defaults toinsert.- When in
bundlemode...- all CSS, whether included as an entry point or
required from JavaScript, will be gathered together into one or more aggregate CSS files and emitted with the rest of the build; - CSS bundles formed from JS
requireexpressions will have a 1:1 correspondence with the JS bundles that required them.
- all CSS, whether included as an entry point or
- When in
insertmode...- all CSS that was
required from JavaScript will be automatically inserted into the DOM as a<style>tag when required at run-time; - all CSS defined as an entry point will be emitted as a CSS bundle with the rest of the build.
- all CSS that was
- When in
objectmode...- all CSS that was
required from JavaScript will be accessible as an object literal in the JS run-time environment; - all CSS defined as an entry point will be emitted as a CSS bundle with the rest of the build.
- all CSS that was
- When in
modules- A boolean. When enabled, treats all required CSS as CSS Modules. This setting has no effect when plugin is inobjectmode. Defaults tofalse.filter- A regular expression. This setting determines which input files will be treated as CSS. Defaults to/\.css$/.plugins- An array of PostCSS plugins.