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
59 lines (54 loc) · 1.2 KB
/
test.js
File metadata and controls
59 lines (54 loc) · 1.2 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
49
50
51
52
53
54
55
56
57
58
59
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,
sourceMap: 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: false,
targets: {
safari: 4 << 16,
firefox: 3 << 16 | 5 << 8,
opera: 10 << 16 | 5 << 8
},
code: Buffer.from(`
.foo {
color: pink;
}
.bar {
color: red;
}
`),
drafts: {
// nesting: true
},
cssModules: {
pattern: '[name]-[hash]-[local]'
},
// analyzeDependencies: true
});
console.log(res.code.toString());
console.log(res.exports);
console.log(require('util').inspect(res.dependencies, { colors: true, depth: 50 }));