From 70592854a802c7f6bd681fca841c985f2392b71e Mon Sep 17 00:00:00 2001 From: Oj Date: Sat, 11 Dec 2021 18:21:59 +0000 Subject: [PATCH] [CI] Strip via JS file, simpler yaml --- .github/workflows/release_nightly.yml | 10 +++++++--- strip.js | 14 ++++++++++++++ 2 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 strip.js diff --git a/.github/workflows/release_nightly.yml b/.github/workflows/release_nightly.yml index 2b43911..cd749b2 100644 --- a/.github/workflows/release_nightly.yml +++ b/.github/workflows/release_nightly.yml @@ -23,13 +23,17 @@ jobs: node-version: 16.x - name: NPM Install - run: cd src; npm i; cd .. + run: | + cd src + npm i; + cd .. + npm i -g asar uglify-js - name: Pack base asar run: | - npm i -g asar + node strip.js node injectPolyfills.js - rm -rf src/package-lock.json src/node_modules/.package-lock.json src/splash/splashScreen.js.self src/node_modules/**/package.json src/node_modules/**/*.md src/node_modules/**/.*.yml src/node_modules/**/.npmignore src/node_modules/**/LICENSE src/node_modules/**/test* + npx asar pack src app.asar # - name: Pack minified asar diff --git a/strip.js b/strip.js new file mode 100644 index 0000000..ec6e18a --- /dev/null +++ b/strip.js @@ -0,0 +1,14 @@ +const { execSync } = require('child_process'); +const { readdirSync } = require('fs'); +const { join } = require('path'); + +// Strip unneeded files in node deps +execSync(`rm -rf src/package-lock.json src/node_modules/.package-lock.json src/node_modules/**/package.json src/node_modules/**/*.md src/node_modules/**/.*.yml src/node_modules/**/.npmignore src/node_modules/**/LICENSE src/node_modules/**/test*`); + +// Minify node deps code + +for (const package of readdirSync('src/node_modules')) { + const indexPath = join('src/node_modules', package, 'index.js'); + + execSync(`npx uglifyjs --compress --mangle -o ${indexPath} -- ${indexPath}`); +} \ No newline at end of file