UPDATE: This is no longer needed because it’s now part of the build process for TS and JS.
@tonyawad88 First of all I would recommend you to not modify anything under node_modules
(unless you want to apply a temporary fix) because your changes will be lost when you update your packages.
If you want to customize your build process you could use the gulpfile.js
file for that purpose.
Disclaimer: I still don’t have any experience with gulp/browserify so this is just a quick example and most probably there’s a much better way to achieve this.
There’s a sample implementation that I made (intentionally works only with the --release
parameter):
// gulpfile.js
// ...
var uglify = require('gulp-uglify');
var isRelease = argv.indexOf('--release') > -1;
var minifyScripts = function(path, done) {
if (isRelease) {
gulp.src(path + '/*.js')
.pipe(uglify({ mangle: false }))
.pipe(gulp.dest(path))
.on('end', done);
} else {
done();
}
};
// ...
gulp.task('build', ['clean'], function(done){
runSequence(
['sass', 'html', 'fonts', 'scripts'],
function(){
//buildBrowserify().on('end', done); // <- replace this line with:
buildBrowserify().on('end', function(){
minifyScripts('www/build/js', done);
});
}
);
});
If you haven’t installed gulp-uglify
you need to install it too:
npm install --save-dev gulp-uglify