Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rollup-plugin-postcss-export

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rollup-plugin-postcss-export

Rollup PostCSS plugin with export to file option

  • 1.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7
decreased by-85.11%
Maintainers
1
Weekly downloads
 
Created
Source

rollup-plugin-postcss-export

Seamless integration between Rollup and PostCSS, witch process the styles and bundle them into 1 external css file;

Installation

npm install rollup-plugin-postcss-export

Rollup import example

Use rollup import system to import styles that will be later processed by rollup. The processed style are concatenated and exported into a single external file

config

import { rollup } from 'rollup';
import postcss from 'rollup-plugin-postcss-export';

rollup({
  entry: 'main.js',
  plugins: [
    postcss({
      extensions: ['.css', '.sss']  // default value
      plugins: [
        // cssnext(),
        // yourPostcssPlugin()
      ],
      sourceMap: true, // defult false
      export: './style.css', // default false
      extensions: ['.css', '.sss']  // default value
      // parser: sugarss
    })
  ]
}).then(...)

entry

import '/path/to/some_random_file.css'

Use with CSS modules

The postcss-modules plugin allows you to use CSS modules in PostCSS, it requires some additional setup to use in Rollup:

import postcss from 'rollup-plugin-postcss-export';
import postcssModules from 'postcss-modules';

const cssExportMap = {};

rollup({
 plugins: [
    postcss({
      plugins: [
        postcssModules({
          getJSON (id, exportTokens) {
            cssExportMap[id] = exportTokens;
          }
        })
      ],
      getExport (id) {
        return cssExportMap[id];
      }
    })
 ]
})

That's it, you can now use CSS modules and import CSS like this:

import style from './style.css';

console.log(style.className); // .className_echwj_1

License

MIT © lmihaidaniel

Keywords

FAQs

Package last updated on 08 Apr 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc