forked from vuejs/rollup-plugin-vue
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstyle.js
41 lines (32 loc) · 815 Bytes
/
style.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { writeFile } from 'fs'
export default function (files, options) {
if (options.css === false) {
return
}
// Combine all stylesheets.
let css = ''
const allStyles = []
Object.keys(files).forEach((file) => {
files[file].forEach((style) => {
css += style.code + '\n'
allStyles.push(style)
})
})
// Emit styles through callback
if (typeof options.css === 'function') {
options.css(css, allStyles)
return
}
// Don't generate empty style file.
if (!css.trim().length) {
return
}
const dest = options.css
if (typeof dest !== 'string') {
return
}
// Emit styles to file
writeFile(dest, css, (err) => {
if (err) throw err
})
};