Skip to content

Commit

Permalink
Merge pull request #252 from TriliumNext/feature/update_reduce_binary…
Browse files Browse the repository at this point in the history
…_size

Reduce dist size
  • Loading branch information
eliandoran authored Jul 20, 2024
2 parents 5b81482 + 758c08e commit 9647738
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 11 deletions.
21 changes: 14 additions & 7 deletions bin/copy-trilium.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,28 @@ cp -Rv "$script_dir/../build/src" "$DIR"
cp "$script_dir/../build/electron.js" "$DIR"

# run in subshell (so we return to original dir)
(cd $DIR && npm install --only=prod)
(cd $DIR && npm install --omit=dev)

if [[ -d "$DIR"/node_modules ]]; then
# cleanup of useless files in dependencies
for d in 'image-q/demo' 'better-sqlite3/Release' 'better-sqlite3/deps/sqlite3.tar.gz' '@jimp/plugin-print/fonts' 'jimp/browser' 'jimp/fonts'; do
[[ -e "$DIR"/node_modules/"$d" ]] && rm -rv "$DIR"/node_modules/"$d"
# cleanup of useless files in dependencies
for d in 'image-q/demo' \
'@excalidraw/excalidraw/dist/excalidraw-assets-dev' '@excalidraw/excalidraw/dist/excalidraw.development.js' '@excalidraw/excalidraw/dist/excalidraw-with-preact.development.js' \
'mermaid/dist/mermaid.js' \
'boxicons/svg' 'boxicons/node_modules/react'/* \
'better-sqlite3/Release' 'better-sqlite3/deps/sqlite3.tar.gz' 'better-sqlite3/deps/sqlite3' \
'@jimp/plugin-print/fonts' 'jimp/browser' 'jimp/fonts'; do
[[ -e "$DIR"/node_modules/"$d" ]] && rm -r "$DIR"/node_modules/"$d"
done

# delete all tests (there are often large images as test file for jimp etc.)
for d in 'test' 'docs' 'demo'; do
find "$DIR"/node_modules -name "$d" -exec rm -rf {} \;
# delete all tests (there are often large images as test file for jimp etc.)
for d in 'test' 'docs' 'demo' 'example'; do
find "$DIR"/node_modules -name "$d" -exec rm -rf {} +
done
fi

find $DIR/libraries -name "*.map" -type f -delete
find $DIR/node_modules -name "*.map" -type f -delete
find $DIR -name "*.ts" -type f -delete

d="$DIR"/src/public
[[ -d "$d"/app-dist ]] || mkdir -pv "$d"/app-dist
Expand Down
22 changes: 19 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@
"react": "^18.3.1",
"react-dom": "^18.3.1",
"request": "2.88.2",
"rimraf": "^6.0.1",
"safe-compare": "1.1.4",
"sanitize-filename": "1.6.3",
"sanitize-html": "^2.13.0",
Expand Down Expand Up @@ -146,6 +145,7 @@
"lorem-ipsum": "2.0.8",
"nodemon": "^3.1.4",
"rcedit": "4.0.1",
"rimraf": "^6.0.1",
"ts-node": "^10.9.2",
"tslib": "^2.6.2",
"typescript": "^5.3.3",
Expand Down

0 comments on commit 9647738

Please sign in to comment.