- Mastering PhoneGap Mobile Application Development
- Kerri Shotts
- 170字
- 2021-07-16 13:03:53
Uglifying your code
Code uglification or minification sounds a bit painful, but it's a really simple step we can add to our workflow. It will reduce the size of our applications when we build in release mode. Uglification also tends to obfuscate our code a little bit, but don't rely on this for any security—obfuscation can be easily undone.
To add code uglification, add the following line of code to the top of our gulp/tasks/copy-code.js
file:
var …, uglify = require("gulp-uglify");
We can then uglify our code by adding the following code immediately after .pipe(concat("app.js"))
in our projectTasks.copyCode
method:
.pipe(isRelease ? uglify({preserveComments: "some"}) : gutil.noop())
Notice that we added the uglify
method only when the build mode was release
. This means that we'll only trigger it if we execute gulp build --mode release
.
You can, of course, specify additional options. If you want to see all the documentation, visit https://github.com/mishoo/UglifyJS2/. Our options include certain comments (which most likely are license-related) while stripping out all the other comments.
- JavaFX Essentials
- Learn Swift by Building Applications
- Learning Salesforce Einstein
- R語言與網絡輿情處理
- IDA Pro權威指南(第2版)
- 計算機應用基礎(第二版)
- R的極客理想:量化投資篇
- Java Web開發基礎與案例教程
- Swift High Performance
- SCRATCH編程課:我的游戲我做主
- 計算機程序的構造和解釋(JavaScript版)
- Java 9:Building Robust Modular Applications
- 軟件自動化測試實戰解析:基于Python3編程語言
- 程序員的算法趣題2
- 零基礎學:微信小程序開發