lib/build.js
function minify( file, options, done ){
		if (_.isFunction(options)){
			done = options;
			options = {};
		}
		if (!_.isObject(options))
			options = {};
		if (!_.isFunction(done))
			done = function(){};

		const canOptimize = options.optimize;
		delete options.optimize;

		console.log("  minify file %s...".grey, file);
		try {
			var code   = fs.readFileSync( file, {encoding: 'utf8'} );
			var minify = UglifyJS.minify( code, options );
		} catch (e) {
			return done(  new Error(`Error on parse file ${e.filename}`) );
		}

		if ( !minify || minify.error ) {
			if ( minify && minify.error )
				return done( new Error(minify.error.message) );
			return done(new Error('Minify error bundle.js') );
		}

		try{
			if ( canOptimize ){
				console.log("  optimize file %s...".grey, file );
				code = optimizeJs(minify.code);
			}else{
				code = minify.code;
			}
		}catch(e){
			console.error("Error on parse file %s", e.filename);
			return next(e);
		}

		fs.writeFile(
			file,
			code,
			function (err) {
				if ( err )
					return done(err);


				return done();
			}
		);
	}
function minify( file, options, done ){
		if (_.isFunction(options)){
			done = options;
			options = {};
		}
		if (!_.isObject(options))
			options = {};
		if (!_.isFunction(done))
			done = function(){};

		const canOptimize = options.optimize;
		delete options.optimize;

		console.log("  minify file %s...".grey, file);
		try {
			var code   = fs.readFileSync( file, {encoding: 'utf8'} );
			var minify = UglifyJS.minify( code, options );
		} catch (e) {
			return done(  new Error(`Error on parse file ${e.filename}`) );
		}

		if ( !minify || minify.error ) {
			if ( minify && minify.error )
				return done( new Error(minify.error.message) );
			return done(new Error('Minify error bundle.js') );
		}

		try{
			if ( canOptimize ){
				console.log("  optimize file %s...".grey, file );
				code = optimizeJs(minify.code);
			}else{
				code = minify.code;
			}
		}catch(e){
			console.error("Error on parse file %s", e.filename);
			return next(e);
		}

		fs.writeFile(
			file,
			code,
			function (err) {
				if ( err )
					return done(err);


				return done();
			}
		);
	}
function minify ( file , options , done ) { if ( _ . isFunction ( options ) ) { done = options ; options = { } ; } if ( ! _ . isObject ( options ) ) options = { } ; if ( ! _ . isFunction ( done ) ) done = function ( ) { } ; const canOptimize = options . optimize ; delete options . optimize ; console . log ( "  minify file %s..." . grey , file ) ; try { var code = fs . readFileSync ( file , { encoding : 'utf8' } ) ; var minify = UglifyJS . minify ( code , options ) ; } catch ( e ) { return done ( new Error ( ` ${ e . filename } ` ) ) ; } if ( ! minify || minify . error ) { if ( minify && minify . error ) return done ( new Error ( minify . error . message ) ) ; return done ( new Error ( 'Minify error bundle.js' ) ) ; } try { if ( canOptimize ) { console . log ( "  optimize file %s..." . grey , file ) ; code = optimizeJs ( minify . code ) ; } else { code = minify . code ; } } catch ( e ) { console . error ( "Error on parse file %s" , e . filename ) ; return next ( e ) ; } fs . writeFile ( file , code , function ( err ) { if ( err ) return done ( err ) ; return done ( ) ; } ) ; }
End bundle Function for minified
End bundle Function for minified