Skip to content

Build your personal knowledge base with Trilium Notes

build(copy-dist): add further cleanupNodeModules functionality

Panagiotis Papadopoulos6749d8084bb6
diff --git a/bin/copy-dist.ts b/bin/copy-dist.ts
index 38413b1b96..9fb520907c 100644
--- a/bin/copy-dist.ts
+++ b/bin/copy-dist.ts
@@ -87,5 +87,18 @@ function cleanupNodeModules() {
.map(el => path.join(DEST_DIR, el.parentPath, el.name))
.forEach(dir => fs.removeSync(dir));
+
+ // Delete unnecessary files based on file extension
+ const filterableFileExt = new Set([
+ "ts",
+ "map"
+ ])
+
+ nodeDir
+ // TriliumNextTODO: check if we can improve this naive file ext matching
+ .filter(el => el.isFile() && filterableFileExt.has(el.name.split(".").at(-1) || ""))
+ .map(file => path.join(DEST_DIR, file.parentPath, file.name))
+ .forEach(file => fs.removeSync(file));
+
}
diff --git a/bin/copy-trilium.sh b/bin/copy-trilium.sh
index e99bf08b92..6aea1175c3 100755
--- a/bin/copy-trilium.sh
+++ b/bin/copy-trilium.sh
@@ -22,7 +22,5 @@ if [[ -d "$BUILD_DIR"/node_modules ]]; then
fi
find $BUILD_DIR/libraries -name "*.map" -type f -delete
-find $BUILD_DIR/node_modules -name "*.map" -type f -delete
-find $BUILD_DIR -name "*.ts" -type f -delete
unset f d BUILD_DIR