npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

rollup-plugin-css-porter

v1.0.2

Published

A rollup plugin to collect all the imported css file

Downloads

5,878

Readme

rollup-plugin-css-porter

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

Installation

Use npm:

npm install --save-dev rollup-plugin-css-porter
// or
npm i -D rollup-plugin-css-porter

Use yarn:

yarn add rollup-plugin-css-porter --dev

Plugin options

| Name | ValueType | Required | Description |----------|-------------------|----------|------------- | dest | String | false | Default value is the same dir of 'bundle.write(options)' options.file | raw | BooleanString | false | 1. Boolean value means whether output a raw css file, default value is true2. String value means output raw css file to this path | minified | BooleanString | false | 1. Boolean value means whether output a minified css file, default value is true2. String value means output minified css file to this path

If set raw or minified option to a String value, dest option will be ignored.

Usage

Case 1 (default behavior):

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'
  });
});

Case 2:

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'
  });
});

Case 3:

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'
  });
});

Case 4:

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'
  });
});

Case 5:

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',
})

Build

Use npm:

npm run build

Use yarn:

yarn run build

Run test

Use npm:

npm test

Use yarn:

yarn test