- 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.
- 數(shù)據(jù)庫系統(tǒng)教程(第2版)
- INSTANT OpenCV Starter
- Building a RESTful Web Service with Spring
- Spring Boot+Spring Cloud+Vue+Element項目實戰(zhàn):手把手教你開發(fā)權(quán)限管理系統(tǒng)
- Access 2016數(shù)據(jù)庫管
- Mastering Predictive Analytics with Python
- Mastering JBoss Enterprise Application Platform 7
- ASP.NET程序設(shè)計教程
- Java Web開發(fā)就該這樣學(xué)
- Clojure for Java Developers
- Unity 5.X從入門到精通
- Android編程權(quán)威指南(第4版)
- SQL Server on Linux
- Flask開發(fā)Web搜索引擎入門與實戰(zhàn)
- 循序漸進(jìn)Vue.js 3前端開發(fā)實戰(zhàn)