From b3544e533647fec9225f912bb844dfab88910e16 Mon Sep 17 00:00:00 2001 From: Vladyslav Hrytsenko Date: Fri, 8 Feb 2019 14:28:33 +0200 Subject: [PATCH] added primitive build size reduce --- misc/reduce.js | 24 ++++++++++++++++++++++++ package.json | 3 ++- 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 misc/reduce.js diff --git a/misc/reduce.js b/misc/reduce.js new file mode 100644 index 00000000..01065ae2 --- /dev/null +++ b/misc/reduce.js @@ -0,0 +1,24 @@ +const fs = require('fs') +const path = require('path') + +/** + * Remove directory recursively + */ +const rm = (target) => { + if (!fs.existsSync(target)) return; + + fs.readdirSync(target).map(entry => { + const entryPath = path.join(target, entry); + const result = fs.lstatSync(entryPath).isDirectory() + ? rm(entryPath) + : fs.unlinkSync(entryPath) + }) + + fs.rmdirSync(target) +} + + +const bin = path.join(__dirname, '..', 'packages', 'nexrender-action-encode', 'node_modules', 'ffmpeg-static', 'bin') + +rm(path.join(bin, 'linux')) +rm(path.join(bin, 'win32', 'ia32')) diff --git a/package.json b/package.json index 7d65102a..e84c8423 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,8 @@ "pkg-worker": "NEXRENDER_REQUIRE_PLUGINS=1 pkg packages/nexrender-worker/package.json --out-path bin/", "pkg-server": "pkg packages/nexrender-server/package.json --out-path bin/", "pkg-prelink": "lerna exec --scope @nexrender/core 'npm run pkg-prelink'", - "pkg": "npm run pkg-prelink && npm run pkg-cli && npm run pkg-server && npm run pkg-worker && npm run pkg-rename", + "pkg-reduce": "node misc/reduce.js", + "pkg": "npm run pkg-prelink && npm run pkg-reduce && npm run pkg-cli && npm run pkg-server && npm run pkg-worker && npm run pkg-rename", "test": "lerna bootstrap && node test.js" }, "devDependencies": {