Skip to content
This repository was archived by the owner on Dec 26, 2018. It is now read-only.

Commit 27a7e7a

Browse files
committed
support out stream for css extraction
1 parent 5f1cf6a commit 27a7e7a

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,11 +287,13 @@ Via API:
287287
browserify('./main.js')
288288
.transform('vueify')
289289
.plugin('vueify/plugins/extract-css', {
290-
out: 'dist/bundle.css'
290+
out: 'dist/bundle.css' // can also be a WritableStream
291291
})
292292
.bundle()
293293
```
294294

295+
This only works for vueify 9+. For Vue 1.x / vueify 8.x you can use [vueify-extract-css](https://github.com/rawcreative/vueify-extract-css).
296+
295297
## Compiler API
296298

297299
The compiler API (originally `vue-component-compiler`) is also exposed:

plugins/extract-css.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,18 @@ module.exports = function (b, opts) {
88

99
var styles = Object.create(null)
1010
var outPath = opts.out || opts.o || 'bundle.css'
11-
if (typeof outPath === 'function') {
12-
outPath = outPath()
13-
}
1411

1512
b.on('bundle', function (bs) {
1613
bs.on('end', function () {
17-
fs.writeFile(outPath, Object.keys(styles)
14+
var css = Object.keys(styles)
1815
.map(function (file) { return styles[file] })
19-
.join('\n'))
16+
.join('\n')
17+
if (typeof outPath === 'object' && outPath.write) {
18+
outPath.write(css)
19+
outPath.end()
20+
} else if (typeof outPath === 'string') {
21+
fs.writeFile(outPath, css)
22+
}
2023
})
2124
})
2225

0 commit comments

Comments
 (0)