From 2965538991c67da9df5478e07fe81071a3b5f1a8 Mon Sep 17 00:00:00 2001 From: CismonX Date: Mon, 29 Mar 2021 01:38:07 +0800 Subject: [PATCH] Reduce vsix file size. --- scripts/package-json-cleanup.js | 17 +++++++++++++++++ scripts/package.sh | 4 ++-- 2 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 scripts/package-json-cleanup.js diff --git a/scripts/package-json-cleanup.js b/scripts/package-json-cleanup.js new file mode 100644 index 0000000..914e346 --- /dev/null +++ b/scripts/package-json-cleanup.js @@ -0,0 +1,17 @@ +/** + * Copyright (C) 2021 CismonX + * + * Copying and distribution of this file, with or without modification, are + * permitted in any medium without royalty, provided the copyright notice and + * this notice are preserved. This file is offered as-is, without any warranty. + */ + +// Removes entries from package.json which is not required in the .vsix file, +// so that the file size can be reduced. +delete this._copyrightNotice; +delete this.devDependencies; +delete this.eslintConfig; +delete this.scripts.build; +delete this.scripts.prepare; +delete this.scripts.lint; +delete this.scripts.watch; diff --git a/scripts/package.sh b/scripts/package.sh index 118b717..e577f55 100755 --- a/scripts/package.sh +++ b/scripts/package.sh @@ -13,8 +13,8 @@ for file in ${JSON_FILES[@]}; do mv $file $file.$BACKUP_SUFFIX json5 -o $file $file.$BACKUP_SUFFIX done -json -j0 -I -e 'delete this.eslintConfig; delete this.devDependencies; delete this._copyrightNotice' -f package.json -vsce package --baseContentUrl=`json -f package.json repository.url` +json -j0 -I -e "$(cat ./scripts/package-json-cleanup.js)" -f package.json +vsce package --baseContentUrl=$(json -f package.json repository.url) for file in ${JSON_FILES[@]}; do mv $file.$BACKUP_SUFFIX $file done