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