@lexho111/plainblog 0.3.4 → 0.3.5
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/Blog.js +1 -1
- package/blog.db +0 -0
- package/build-styles.js +38 -18
- package/package.json +1 -1
- package/test_1767119505118.db +0 -0
package/Blog.js
CHANGED
|
@@ -509,7 +509,7 @@ export default class Blog {
|
|
|
509
509
|
this.#stylesHash = currentHash;
|
|
510
510
|
|
|
511
511
|
// Compile styles using the standalone script
|
|
512
|
-
this.compiledStyles = await compileStyles();
|
|
512
|
+
this.compiledStyles = await compileStyles(fileData);
|
|
513
513
|
|
|
514
514
|
await fs.promises.writeFile(
|
|
515
515
|
path.join(__dirname, "styles.min.css"),
|
package/blog.db
CHANGED
|
Binary file
|
package/build-styles.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { promises as fs } from "fs";
|
|
2
2
|
import path from "path";
|
|
3
|
+
import { pathToFileURL } from "url";
|
|
3
4
|
import * as sass from "sass";
|
|
4
5
|
import postcss from "postcss";
|
|
5
6
|
import autoprefixer from "autoprefixer";
|
|
@@ -20,28 +21,47 @@ async function getFiles(dir) {
|
|
|
20
21
|
return Array.prototype.concat(...files);
|
|
21
22
|
}
|
|
22
23
|
|
|
23
|
-
export async function compileStyles() {
|
|
24
|
+
export async function compileStyles(fileData) {
|
|
24
25
|
try {
|
|
25
|
-
|
|
26
|
+
let combinedCss = "";
|
|
26
27
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
if (fileData) {
|
|
29
|
+
const scssFiles = fileData.filter(
|
|
30
|
+
(f) =>
|
|
31
|
+
f.path.endsWith(".scss") && !path.basename(f.path).startsWith("_")
|
|
32
|
+
);
|
|
32
33
|
|
|
33
|
-
|
|
34
|
+
for (const file of scssFiles) {
|
|
35
|
+
try {
|
|
36
|
+
const result = sass.compileString(file.content.toString(), {
|
|
37
|
+
loadPaths: [srcDir],
|
|
38
|
+
style: "expanded",
|
|
39
|
+
url: pathToFileURL(file.path),
|
|
40
|
+
});
|
|
41
|
+
combinedCss += result.css + "\n";
|
|
42
|
+
} catch (err) {
|
|
43
|
+
console.error(
|
|
44
|
+
`Error compiling ${path.basename(file.path)}:`,
|
|
45
|
+
err.message
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
} else {
|
|
50
|
+
const allFiles = await getFiles(srcDir);
|
|
51
|
+
const scssFiles = allFiles
|
|
52
|
+
.filter((f) => f.endsWith(".scss") && !path.basename(f).startsWith("_"))
|
|
53
|
+
.sort();
|
|
34
54
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
55
|
+
for (const file of scssFiles) {
|
|
56
|
+
try {
|
|
57
|
+
const result = sass.compile(file, {
|
|
58
|
+
loadPaths: [srcDir],
|
|
59
|
+
style: "expanded",
|
|
60
|
+
});
|
|
61
|
+
combinedCss += result.css + "\n";
|
|
62
|
+
} catch (err) {
|
|
63
|
+
console.error(`Error compiling ${path.basename(file)}:`, err.message);
|
|
64
|
+
}
|
|
45
65
|
}
|
|
46
66
|
}
|
|
47
67
|
|
package/package.json
CHANGED
|
Binary file
|