Skip to content

Commit c4fd492

Browse files
committed
v1.0.2
1 parent 0d1dd8b commit c4fd492

File tree

2 files changed

+57
-6
lines changed

2 files changed

+57
-6
lines changed

README.md

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,50 @@
11
# rollup-plugin-css-bundle
2-
Rollup plugin to extract CSS into a single external file.
2+
3+
A [Rollup](https://github.com/rollup/rollup) plugin who's sole purpose is to collect all the CSS files you import into your project and bundle them to a single CSS file.
4+
5+
## Usage
6+
7+
```js
8+
// rollup.config.js
9+
import cssbundle from 'rollup-plugin-css-bundle';
10+
11+
export default {
12+
input: 'index.js',
13+
output: {
14+
file: 'dist/index.js',
15+
format: 'cjs'
16+
},
17+
plugins: {
18+
cssbundle()
19+
}
20+
}
21+
```
22+
23+
## Options
24+
25+
Like all good-behaved Rollup plugins, `cssbundle` supports the `include` and `exclude` options that let you configure on which files the plugin should run. Additionally:
26+
27+
__output__: _String_ is an optional path wherein to put the extracted CSS; when ommitted, we use the bundle's filename to fashion a name for the bundled CSS.
28+
29+
__transform__: _Function_ is available for processing the CSS, such as with [postcss](https://github.com/postcss/postcss). It receives a string containing the code to process as its only parameter, and should return the processed code:
30+
31+
```js
32+
// rollup.config.js
33+
34+
import cssbundle from 'rollup-plugin-css-bundle';
35+
import postcss from 'postcss';
36+
import autoprefixer from 'autoprefixer';
37+
38+
export default {
39+
input: 'index.js',
40+
output: {
41+
file: 'dist/index.js',
42+
format: 'cjs'
43+
},
44+
plugins: [
45+
cssbundle({
46+
transform: code => postcss([autoprefixer]).process(code, {})
47+
})
48+
]
49+
};
50+
```

package.json

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
{
2-
"dependencies": {
3-
"fs-extra": "^5.0.0",
4-
"rollup-pluginutils": "^2.0.1"
5-
},
62
"name": "rollup-plugin-css-bundle",
7-
"version": "1.0.1",
3+
"version": "1.0.2",
84
"main": "dist/index.js",
95
"module": "src/index.js",
106
"repository": "git@github.com:danburzo/rollup-plugin-css-bundle.git",
117
"author": "Dan Burzo <danburzo@gmail.com>",
8+
"keywords": [
9+
"rollup-plugin"
10+
],
1211
"license": "MIT",
1312
"files": [
1413
"src",
@@ -17,6 +16,10 @@
1716
"devDependencies": {
1817
"rollup": "^0.58.1"
1918
},
19+
"dependencies": {
20+
"fs-extra": "^5.0.0",
21+
"rollup-pluginutils": "^2.0.1"
22+
},
2023
"scripts": {
2124
"build": "rollup -c",
2225
"watch": "rollup -w -c"

0 commit comments

Comments
 (0)