A rollup plugin to collect and combine all the imported css file. Such as import './my.css'.
Then output them to a standalone css file. Besides, use clean-css
to create a minified css file as you wish.
Supported rollup version :
| plugin version | rollup version | 
|---|---|
| 1.x | 1.0.0+ | 
| 0.3.x | 0.48.0~0.68.2 | 
| 0.1.0~0.2.x | 0.36.0~0.47.6 | 
Use npm:
npm install --save-dev rollup-plugin-css-porter
// or
npm i -D rollup-plugin-css-porterUse yarn:
yarn add rollup-plugin-css-porter --dev| Name | ValueType | Required | Description | 
|---|---|---|---|
| dest | String | false | Default value is the same dir of 'bundle.write(options)'options.file | 
| raw | BooleanString | false | 1. Booleanvalue means whether output a raw css file, default value istrue2. Stringvalue means output raw css file to this path | 
| minified | BooleanString | false | 1. Booleanvalue means whether output a minified css file, default value istrue2. Stringvalue means output minified css file to this path | 
If set
raworminifiedoption to aStringvalue,destoption will be ignored.
Output to a standalone css file and a minified css file.
The output destination is the same dir of 'bundle.write(options)' options.file.
import { rollup } from 'rollup';
import css from 'rollup-plugin-css-porter';
rollup({
  input: 'main.js',
  plugins: [ css() ]
}).then(bundle => {
  bundle.write({
    format: 'es',
    file: 'bundle.js'
  });
});Output to a standalone css file without minified css file.
The output destination is the same dir of 'bundle.write(options)' options.file.
import { rollup } from 'rollup';
import css from 'rollup-plugin-css-porter';
rollup({
  input: 'main.js',
  plugins: [ css({minified: false}) ]
}).then(bundle => {
  bundle.write({
    format: 'es',
    file: 'bundle.js'
  });
});Output to a specific path if config the plugin options.dest.
import { rollup } from 'rollup';
import css from 'rollup-plugin-css-porter';
rollup({
  input: 'main.js',
  plugins: [ css({dest: 'path-to-my-dir/bundle.css'}) ]
}).then(bundle => {
  bundle.write({
    format: 'es',
    file: 'bundle.js'
  });
});Output to a standalone css file with only minified css file.
The output destination is the same dir of 'bundle.write(options)' options.file.
import { rollup } from 'rollup';
import css from 'rollup-plugin-css-porter';
rollup({
  input: 'main.js',
  plugins: [ css({raw: false}) ]
}).then(bundle => {
  bundle.write({
    format: 'es',
    file: 'bundle.js'
  });
});Custom output filenames by config a string value for plugin raw and minified option :
import { rollup } from 'rollup';
import css from 'rollup-plugin-css-porter';
rollup({
  input: 'main.js',
  plugins: [ css({
    raw: 'custom.css',
    minified: 'custom.min.css',
  }) ]
}).then(bundle => {
  bundle.write({
    format: 'es',
    file: 'bundle.js'
  });
});Or:
css({
  raw: 'custom.css',
  minified: false,
})Or:
css({
  raw: false,
  minified: 'custom.min.css',
})Use npm:
npm run buildUse yarn:
yarn run buildUse npm:
npm testUse yarn:
yarn test