1.0.3 • Published 7 years ago

rollup-plugin-postcss-export v1.0.3

Weekly downloads
35
License
MIT
Repository
github
Last release
7 years ago

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

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago

0.3.3

7 years ago

0.3.2

7 years ago

0.3.1

7 years ago

0.3.0

7 years ago

0.2.0

7 years ago

0.1.9

7 years ago

0.1.8

7 years ago

0.1.7

7 years ago

0.1.6

7 years ago

0.1.5

7 years ago

0.1.4

7 years ago

0.1.3

7 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago