@unizap/unicss 2.0.6 → 2.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/index.js +14 -6
- package/dist/index.js +58 -58
- package/dist/unicss.min.js +13 -13
- package/package.json +1 -1
package/bin/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
1
|
+
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
const path = require("path");
|
|
4
4
|
const fs = require("fs");
|
|
@@ -7,7 +7,8 @@ const generateCSS = require("../dist/index.js");
|
|
|
7
7
|
const args = process.argv.slice(2);
|
|
8
8
|
let outFile = "style/unicss.css";
|
|
9
9
|
let watch = false;
|
|
10
|
-
let skipBase = false;
|
|
10
|
+
let skipBase = false;
|
|
11
|
+
let content = null;
|
|
11
12
|
|
|
12
13
|
for (let i = 0; i < args.length; i++) {
|
|
13
14
|
if ((args[i] === "-o" || args[i] === "--output") && args[i + 1]) {
|
|
@@ -17,13 +18,19 @@ for (let i = 0; i < args.length; i++) {
|
|
|
17
18
|
if (args[i] === "-w" || args[i] === "--watch") {
|
|
18
19
|
watch = true;
|
|
19
20
|
}
|
|
20
|
-
if (args[i] === "--skip-base") {
|
|
21
|
+
if (args[i] === "--skip-base") {
|
|
21
22
|
skipBase = true;
|
|
22
23
|
}
|
|
24
|
+
if ((args[i] === "-c" || args[i] === "--content") && args[i + 1]) {
|
|
25
|
+
// Support multiple patterns separated by comma or multiple --content flags
|
|
26
|
+
const patterns = args[i + 1].split(",").map(p => p.trim());
|
|
27
|
+
content = content ? [...content, ...patterns] : patterns;
|
|
28
|
+
i++;
|
|
29
|
+
}
|
|
23
30
|
}
|
|
24
31
|
|
|
25
32
|
function run() {
|
|
26
|
-
const css = generateCSS({ skipBase });
|
|
33
|
+
const css = generateCSS({ skipBase, content });
|
|
27
34
|
const outDir = path.dirname(outFile);
|
|
28
35
|
if (!fs.existsSync(outDir)) {
|
|
29
36
|
fs.mkdirSync(outDir, { recursive: true });
|
|
@@ -36,9 +43,10 @@ run();
|
|
|
36
43
|
|
|
37
44
|
if (watch) {
|
|
38
45
|
const chokidar = require("chokidar");
|
|
39
|
-
// Watch
|
|
46
|
+
// Watch content patterns or default patterns, plus the config
|
|
47
|
+
const watchPatterns = content || ["**/*.{js,jsx,ts,tsx,html,vue}"];
|
|
40
48
|
const watcher = chokidar.watch([
|
|
41
|
-
|
|
49
|
+
...watchPatterns,
|
|
42
50
|
"unicss.config.js"
|
|
43
51
|
], { ignoreInitial: true });
|
|
44
52
|
watcher.on("all", () => {
|