### Install rollup-plugin-styles Source: https://github.com/anidetrix/rollup-plugin-styles/blob/main/README.md Install the plugin using npm, pnpm, or yarn. ```bash # npm npm install -D rollup-plugin-styles # pnpm pnpm add -D rollup-plugin-styles # yarn yarn add rollup-plugin-styles --dev ``` -------------------------------- ### Install Stylus Dependency (yarn) Source: https://github.com/anidetrix/rollup-plugin-styles/blob/main/README.md Install the Stylus preprocessor using yarn for use with rollup-plugin-styles. ```bash # yarn yarn add stylus --dev ``` -------------------------------- ### Install Stylus Dependency (pnpm) Source: https://github.com/anidetrix/rollup-plugin-styles/blob/main/README.md Install the Stylus preprocessor using pnpm for use with rollup-plugin-styles. ```bash # pnpm pnpm add -D stylus ``` -------------------------------- ### Install Less Dependency (yarn) Source: https://github.com/anidetrix/rollup-plugin-styles/blob/main/README.md Install the Less preprocessor using yarn for use with rollup-plugin-styles. ```bash # yarn yarn add less --dev ``` -------------------------------- ### Install Node-Sass Dependency (pnpm) Source: https://github.com/anidetrix/rollup-plugin-styles/blob/main/README.md Install the node-sass preprocessor using pnpm for use with rollup-plugin-styles. ```bash # pnpm pnpm add -D node-sass ``` -------------------------------- ### Install Sass Dependency (yarn) Source: https://github.com/anidetrix/rollup-plugin-styles/blob/main/README.md Install the Sass preprocessor using yarn for use with rollup-plugin-styles. ```bash # yarn yarn add sass --dev ``` -------------------------------- ### Install Less Dependency (npm) Source: https://github.com/anidetrix/rollup-plugin-styles/blob/main/README.md Install the Less preprocessor using npm for use with rollup-plugin-styles. ```bash # npm npm install -D less ``` -------------------------------- ### Install Sass Dependency (pnpm) Source: https://github.com/anidetrix/rollup-plugin-styles/blob/main/README.md Install the Sass preprocessor using pnpm for use with rollup-plugin-styles. ```bash # pnpm pnpm add -D sass ``` -------------------------------- ### Install Less Dependency (pnpm) Source: https://github.com/anidetrix/rollup-plugin-styles/blob/main/README.md Install the Less preprocessor using pnpm for use with rollup-plugin-styles. ```bash # pnpm pnpm add -D less ``` -------------------------------- ### Install Node-Sass Dependency (yarn) Source: https://github.com/anidetrix/rollup-plugin-styles/blob/main/README.md Install the node-sass preprocessor using yarn for use with rollup-plugin-styles. ```bash # yarn yarn add node-sass --dev ``` -------------------------------- ### Install Stylus Dependency (npm) Source: https://github.com/anidetrix/rollup-plugin-styles/blob/main/README.md Install the Stylus preprocessor using npm for use with rollup-plugin-styles. ```bash # npm npm install -D stylus ``` -------------------------------- ### Install Sass Dependency (npm) Source: https://github.com/anidetrix/rollup-plugin-styles/blob/main/README.md Install the Sass preprocessor using npm for use with rollup-plugin-styles. ```bash # npm npm install -D sass ``` -------------------------------- ### Install Node-Sass Dependency (npm) Source: https://github.com/anidetrix/rollup-plugin-styles/blob/main/README.md Install the node-sass preprocessor using npm for use with rollup-plugin-styles. ```bash # npm npm install -D node-sass ``` -------------------------------- ### Basic Rollup Configuration Source: https://github.com/anidetrix/rollup-plugin-styles/blob/main/README.md Configure Rollup to use rollup-plugin-styles. This example sets the output asset file name pattern. ```javascript // rollup.config.js import styles from "rollup-plugin-styles"; export default { output: { // Governs names of CSS files (for assets from CSS use `hash` option for url handler). // Note: using value below will put `.css` files near js, // but make sure to adjust `hash`, `assetDir` and `publicPath` // options for url handler accordingly. assetFileNames: "[name]-[hash][extname]", }, plugins: [styles()], }; ``` -------------------------------- ### Sass/Less Import Syntax Source: https://github.com/anidetrix/rollup-plugin-styles/blob/main/README.md Shows how to import Sass and Less files, using the `~` prefix to resolve modules from `node_modules`. ```scss // Import from `node_modules` @import "~bulma/css/bulma"; // Local import @import "./custom"; // ...or @import "custom"; ``` -------------------------------- ### CSS/Stylus Import Syntax Source: https://github.com/anidetrix/rollup-plugin-styles/blob/main/README.md Demonstrates how to use `@import` statements for CSS and Stylus files, including imports from `node_modules` and local files. ```css /* Import from `node_modules` */ @import "bulma/css/bulma"; /* Local import */ @import "./custom"; /* ...or (if no package named `custom` in `node_modules`) */ @import "custom"; ``` -------------------------------- ### Sass/Less Partial Import Behavior Source: https://github.com/anidetrix/rollup-plugin-styles/blob/main/README.md Illustrates how Sass and Less handle partial imports, prioritizing underscored filenames (e.g., `_custom.scss`). ```scss import "custom"; Will look for `_custom` first (_with the appropriate extension(s)_), and then for `custom` if `_custom` doesn't exist. ``` -------------------------------- ### Configure CSS Modules Source: https://github.com/anidetrix/rollup-plugin-styles/blob/main/README.md Enable and configure CSS Modules support within rollup-plugin-styles. Options include enabling with default settings, custom options, auto-detection, or a custom function for module identification. ```javascript styles({ modules: true, // ...or with custom options modules: {}, // ...additionally using autoModules autoModules: true, // ...with custom regex autoModules: /\.mod\.\S+$/, // ...or custom function autoModules: id => id.includes(".modular."), }); ``` -------------------------------- ### CSS Injection with Custom Options Source: https://github.com/anidetrix/rollup-plugin-styles/blob/main/README.md Configure the 'inject' mode for CSS, allowing customization of the injection target, tag behavior, and attributes. ```javascript styles({ mode: "inject", // Unnecessary, set by default // ...or with custom options for injector mode: [ "inject", { container: "body", singleTag: true, prepend: true, attributes: { id: "global" } }, ], // ...or with custom injector mode: ["inject", (varname, id) => `console.log(${varname},${JSON.stringify(id)})`], }); ``` -------------------------------- ### Importing CSS in JavaScript Source: https://github.com/anidetrix/rollup-plugin-styles/blob/main/README.md Import CSS files directly into your JavaScript code after configuring the plugin. ```javascript import "./style.css"; ``` -------------------------------- ### Emit Processed CSS Source: https://github.com/anidetrix/rollup-plugin-styles/blob/main/README.md Configure rollup-plugin-styles to emit processed CSS as a separate file. Ensure this plugin is listed before any plugin that consumes pure CSS. ```javascript // rollup.config.js import styles from "rollup-plugin-styles"; // Any plugin which consumes pure CSS import litcss from "rollup-plugin-lit-css"; export default { plugins: [ styles({ mode: "emit" }), // Make sure to list it after this one litcss(), ], }; ``` -------------------------------- ### CSS Extraction Configuration Source: https://github.com/anidetrix/rollup-plugin-styles/blob/main/README.md Configure the 'extract' mode to save processed CSS into a separate file. The filename can be specified directly or relative to the output directory. ```javascript styles({ mode: "extract", // ... or with relative to output dir/output file's basedir (but not outside of it) mode: ["extract", "awesome-bundle.css"], }); ``` -------------------------------- ### CSS Import with Named Export Source: https://github.com/anidetrix/rollup-plugin-styles/blob/main/README.md Access CSS content as a named export when CSS Modules are enabled or when using specific modes. ```javascript // Injects CSS, also available as `style` in this example import style from "./style.css"; // Using named export of CSS string import { css } from "./style.css"; ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.