From 1876b31eb47b42c93201a36b12ea94180c4dcd54 Mon Sep 17 00:00:00 2001 From: Florian Hartwich Date: Sat, 29 Jul 2017 11:46:01 +0200 Subject: [PATCH] Minify webpack output --- minify.sh | 11 +++++++++++ package.json | 3 ++- static/src/tsconfig.app.json | 8 ++++---- static/tsconfig.json | 2 +- 4 files changed, 18 insertions(+), 6 deletions(-) create mode 100755 minify.sh diff --git a/minify.sh b/minify.sh new file mode 100755 index 0000000..64f59f6 --- /dev/null +++ b/minify.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +# array of files to minify +FILES=(inline main polyfills scripts styles vendor) +OPTIONS="-c toplevel,dead_code=true,unused=true" + +for i in "${FILES[@]}" +do + echo "minify ${i} ..." + $(npm bin)/uglifyjs public/${i}.bundle.js ${OPTIONS} -o public/${i}.bundle.js +done diff --git a/package.json b/package.json index ec4f66a..1c47789 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,8 @@ "start": "npm run deploy-static-prod && npm start --prefix ./api", "dev": "npm run deploy-static && npm run dev --prefix ./api", "deploy-static": "cd ./static && $(npm bin)/ng build && ln -s ../api/resource/ ../public/resource", - "deploy-static-prod": "cd ./static && $(npm bin)/ng build --env=prod && ln -s ../api/resource/ ../public/resource", + "deploy-static-prod": "cd ./static && $(npm bin)/ng build --env=prod && ln -s ../api/resource/ ../public/resource && cd .. && npm run deploy-minify", + "deploy-minify": "./minify.sh", "postinstall": "npm install --prefix ./static && npm install --prefix ./api", "mongodb": "mkdir -p mongodb-data && mongod --dbpath ./mongodb-data", "test": "npm test --prefix ./api", diff --git a/static/src/tsconfig.app.json b/static/src/tsconfig.app.json index b063a4a..a986ca9 100644 --- a/static/src/tsconfig.app.json +++ b/static/src/tsconfig.app.json @@ -1,10 +1,10 @@ { "extends": "../tsconfig.json", "compilerOptions": { - "lib": [ - "es2016", - "dom" - ], + "lib": [ + "es2016", + "dom" + ], "outDir": "../out-tsc/app", "target": "es5", "module": "es2015", diff --git a/static/tsconfig.json b/static/tsconfig.json index 7a9d9e8..732f40e 100644 --- a/static/tsconfig.json +++ b/static/tsconfig.json @@ -2,7 +2,7 @@ "compileOnSave": false, "compilerOptions": { "outDir": "./dist/out-tsc", - "sourceMap": true, + "sourceMap": false, "declaration": false, "moduleResolution": "node", "emitDecoratorMetadata": true, -- 2.25.1