Skip to content

Commit

Permalink
Add in post build step to minify code using UglifyJS
Browse files Browse the repository at this point in the history
I tried to use a couple of things integrated directly with babel,

+ https:/babel/babili - Issue with es2015 preset babel/minify#556
+ https:/rreverser/babel-plugin-uglify - Just didn't work!

So, added in a script using the UglifyJS2 CLI tool which saves ~20% of
the size! ✌
  • Loading branch information
domtronn committed Jun 9, 2017
1 parent 36e7546 commit 1c6d118
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"description": "uStyle React Components",
"main": "dist/index.js",
"scripts": {
"build": "rm -rf dist; babel src --out-dir dist",
"build": "rm -rf dist; babel src --out-dir dist; echo Pre-Minify: `du -sh dist | cut -f1`",
"postbuild": "find dist -type f -exec uglifyjs {} --mangle --compress -o {} \\;; echo Post-Minify: `du -sh dist | cut -f1`",
"start": "webpack-dev-server",
"commit-dist": "npm run build; npm run lint:fix; git add dist",
"bump-version": "nver; git add package.json",
Expand Down Expand Up @@ -34,8 +35,6 @@
"react": ">=15.3"
},
"devDependencies": {
"react": ">=15.3",
"react-dom": ">=15.3",
"babel-cli": "^6.24.0",
"babel-core": "^6.24.0",
"babel-loader": "^6.4.1",
Expand All @@ -44,8 +43,11 @@
"nodemon": "^1.11.0",
"nver": "^0.0.15",
"pre-commit": "^1.2.2",
"react": ">=15.3",
"react-dom": ">=15.3",
"standard": "^10.0.2",
"uglify-js": "^3.0.15",
"webpack": "^2.3.3",
"webpack-dev-server": "^2.4.2"
}
}
}

0 comments on commit 1c6d118

Please sign in to comment.