Skip to content

Commit a81c78e

Browse files
committed
feat: update build scripts and add CSS minification functionality
1 parent da14f9d commit a81c78e

File tree

6 files changed

+71
-249
lines changed

6 files changed

+71
-249
lines changed

_build_scripts/build-component.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as esbuild from "https://deno.land/x/[email protected]/mod.js";
22
import { copy } from "https://deno.land/[email protected]/fs/mod.ts";
3+
import { minify as minifyCss } from "https://esm.sh/[email protected]";
34

45
export async function buildComponent(componentName: string) {
56
console.log(`Building ${componentName}`);
@@ -41,13 +42,28 @@ async function copy_files(componentName: string) {
4142
await copyFilesToFolder(`${srcFolder}/${entry.name}`, `${distFolder}/${entry.name}`);
4243
continue;
4344
}
45+
46+
if (entry.name.endsWith(".css")) {
47+
await copyCSSFiles(`${srcFolder}/${entry.name}`, `${distFolder}/${entry.name}`);
48+
continue;
49+
}
4450

4551
const srcPath = `${srcFolder}/${entry.name}`;
4652
const distPath = `${distFolder}/${entry.name}`;
4753
await copy(srcPath, distPath, { overwrite: true });
4854
}
4955
}
5056

57+
async function copyCSSFiles(srcFile: string, distFile: string) {
58+
const css = await Deno.readTextFile(srcFile);
59+
const result = await minifyCss(css);
60+
await Deno.writeTextFile(distFile, result.css);
61+
}
62+
63+
async function copyHTMLFiles(srcFolder: string, distFolder: string) {
64+
65+
}
66+
5167
async function copyFilesToFolder(sourceDir: string, targetDir: string) {
5268
for await (const entry of Deno.readDir(sourceDir)) {
5369
const srcPath = `${sourceDir}/${entry.name}`;

deno.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
{
2+
"nodeModulesDir": "auto",
23
"tasks": {
34
"surreal": "surreal start --user root --password root surrealkv:./data/mydatabase.db",
4-
"compile_markdown": "wasm-pack build ./wasm/markdown/ --target web --out-dir ./../../src/modules/markdown"
5+
"compile_markdown": "wasm-pack build ./wasm/markdown/ --target web --out-dir ./../../src/modules/markdown",
6+
"build": "deno run --allow-all _build_scripts/build.ts"
57
},
68
"fmt": {
79
"useTabs": true

deno.lock

Lines changed: 52 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 0 additions & 140 deletions
This file was deleted.

package.json

Lines changed: 0 additions & 25 deletions
This file was deleted.

playwright.config.js

Lines changed: 0 additions & 81 deletions
This file was deleted.

0 commit comments

Comments
 (0)