forked from parcel-bundler/lightningcss
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
48 lines (43 loc) · 1.02 KB
/
test.js
File metadata and controls
48 lines (43 loc) · 1.02 KB
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
42
43
44
45
46
47
48
const css = require('./');
const fs = require('fs');
if (process.argv[process.argv.length - 1] !== __filename) {
let opts = {
filename: process.argv[process.argv.length - 1],
code: fs.readFileSync(process.argv[process.argv.length - 1]),
minify: true,
source_map: true,
targets: {
chrome: 95 << 16
}
};
console.time('optimize');
let r = css.transform(opts);
console.timeEnd('optimize')
// console.log(r.toString());
console.log(r);
let code = r.code;
if (r.map) {
code = code.toString() + `\n/*# sourceMappingURL=out.css.map */\n`;
}
fs.writeFileSync('out.css', code);
if (r.map) {
fs.writeFileSync('out.css.map', r.map);
}
return;
}
let res = css.transform({
filename: __filename,
minify: true,
targets: {
safari: 4 << 16,
firefox: 3 << 16 | 5 << 8,
opera: 10 << 16 | 5 << 8
},
code: Buffer.from(`
.foo + .bar:not(.baz) {
-webkit-box-shadow: 2px 0 0 blue;
box-shadow: 2px 0 0 red;
box-sizing: border-box;
}
`)});
console.log(res.code.toString());