-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.js
35 lines (27 loc) · 961 Bytes
/
index.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
'use strict';
var semver = require('semver');
var css = require('borschik/lib/techs/css');
exports.Tech = css.Tech.inherit({
minimize: function(content) {
var csso = require('csso'); // lazy require
var cssoOptions = this.opts && this.opts.techOptions && this.opts.techOptions.csso || {};
// CSSO version less than 1.4.0
if (!csso.version && !csso.minify) {
return csso.justDoIt(csso);
}
// CSSO 1.4.x
if (!csso.version && csso.minify) {
return csso.minify(csso);
}
// CSSO ^1.5.0
if (semver.satisfies(csso.version, '1.x')) {
return csso.minify(content, cssoOptions);
}
// CSSO 2.x
if (semver.satisfies(csso.version, '2.x')) {
return csso.minify(content, cssoOptions).css;
}
throw Error('Borschik does not support CSSO version ' + csso.version);
}
});
exports.File = css.File;