-
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathindex.m.js
More file actions
27 lines (21 loc) · 569 Bytes
/
index.m.js
File metadata and controls
27 lines (21 loc) · 569 Bytes
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
'use strict'
import postcss from 'postcss'
import CleanCss from 'clean-css'
const initializer = (opts = {}) => {
const cleancss = new CleanCss(opts)
return (css, res) => {
return new Promise((resolve, reject) => {
cleancss.minify(css.toString(), (err, min) => {
if (err) {
return reject(new Error(err.join('\n')))
}
for (let w of min.warnings) {
res.warn(w)
}
res.root = postcss.parse(min.styles)
resolve()
})
})
}
}
export default postcss.plugin('clean', initializer)