Package detail

rollup-plugin-css-only

thgh202.5kMIT4.5.4

Rollup plugin that bundles imported css

rollup-plugin, css

readme

Rollup plugin that bundles imported css

Software License Issues JavaScript Style Guide NPM Latest Version

Features

  • CSS is emitted as 1 asset
  • Order of imports is guaranteed
  • Watches CSS imports
  • Typescript types

Installation

# v4 is compatible with Rollup 4 & 3 & 2
# Rollup 4 since v4.4
npm install --save-dev rollup-plugin-css-only

Usage

// rollup.config.js
import css from 'rollup-plugin-css-only'

export default {
  input: 'input.js',
  output: {
    file: 'output.js',
    format: 'es',
    assetFileNames: 'assets/[name]-[hash][extname]'
  },
  plugins: [css()]
}
// entry.js
import './reset.css'
import './layout.css'
/* layout.css */
@import './nested.css';
@import './more.css';

Options

There is 1 option: output.
By default the plugin will use output.assetFileNames to decide the filename.

css({
  // Optional: filename to write all styles to
  output: 'bundle.css'
})

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Contributions and feedback are very welcome.

To get it running:

  1. Clone the project.
  2. npm install
  3. npm run build

Credits

License

The MIT License (MIT). Please see License File for more information.

changelog

Changelog

All notable changes to rollup-plugin-css-only will be documented in this file.

Unreleased

[4.5.3] - 2025-09-03

Changed

[4.5.2] - 2023-11-07

Changed

[4.4.0] - 2023-11-01

Changed

  • Support Rollup v4 as peerDependencies

Changed

  • Mark visited modules to avoid infinite recursion

[4.3.0] - 2022-11-04

Changed

  • Mark visited modules to avoid infinite recursion

[4.2.0] - 2022-10-25

Changed

  • Fix issue when module info is null

[4.1.1] - 2022-10-21

Changed

  • Always append newline to asset to make it's generated

[4.1.0] - 2022-10-20

Changed

  • Simplify name/fileName by making them explicit options

[4.0.0] - 2020-12-18

Changed

  • BREAKING CHANGE: CSS is emitted as 1 asset instead of written using writeFile.
  • Order of imports is guaranteed
  • Require @rollup/pluginutils@4

Added

  • Mark as compatible with rollup 3 #45 @el3um4s

[3.1.0] - 2020-12-18

Changed

  • Require @rollup/pluginutils@4

[3.0.0] - 2020-11-19

Changed

  • Maintain import order of stylesheets when combining #21 @staydecent
  • Use emitFile instead of outputFile #24 @benmccann
  • Upgrade dependencies @thgh

[2.1.0] - 2020-06-02

Added

  • Mark as compatible with rollup 2 #14 @yagebu

Changed

  • Fix file writing errors #19 @aminya
  • Upgrade dependencies #14 @yagebu

2.0.0 - 2019-12-21

Added

  • Add bundle as 3rd argument in output function @lazyhero

Changed

  • Replace mkdirp by fs.mkdir (Node.js 10.12+) @MichaelAllenHardeman

1.0.0 - 2019-01-27

Added

  • Add ES modules build: dist/index.es.js

Changed

  • Migrate to Rollup v1 @tlvince