Cleaning Your Compiling Code with the JET Build Script

Jason Scarfe
Oracle Developers
Published in
2 min readDec 6, 2017

The title sounds ominous but what I mean by this is when you go to release your application for deployment there maybe some methods you don’t want to end up there.

For example you might have some development methods such as logging which you don’t want within your production environment.

Once again, JET pulls it out the bag with the toolkit. We can simply do this using the build script supplied to us as part of the scaffolding process.

For my example, I am removing my “all so common” console.info statements.

So, within the following file:

Pre v4.0
$JET_PROJECT/scripts/grunt/config/oraclejet-build.js
v4.0 Onwards
$JET_PROJECT/scripts/config/oraclejet-build.js

You will find the #uglify section of the file. This file contains a lot of useful things such as copying third party libraries to your src from the node_modules directory.

Anyway, back to why we are here. The options object which gets sent to the uglify process (on release only as the comments suggest!) can be supplied with a compress object which holds methods to remove.

This is all rather wordy so lets see that in action as it really is worth a thousand words:

Here is the code so you can copy and paste:

uglify: {
// fileList: [{}],
options: { compress:{
pure_funcs: [ ‘console.info’ ]
}}
},

So this means you can put as many console.info snippets into your code and not worry about them appearing in production.

I found this to be incredibly useful and sped up the time it takes to deploy dramatically.

Thanks again, JET toolkit!

--

--