1- var fs = require ( 'fs' ) ;
2- var path = require ( 'path' ) ;
3-
4- var browserify = require ( 'browserify' ) ;
5- var UglifyJS = require ( 'uglify-js' ) ;
6-
71var constants = require ( './util/constants' ) ;
82var common = require ( './util/common' ) ;
9- var compressAttributes = require ( './util/compress_attributes' ) ;
10- var patchMinified = require ( './util/patch_minified' ) ;
11- var doesFileExist = common . doesFileExist ;
3+ var _bundle = require ( './util/browserify_wrapper' ) ;
124
135/*
146 * This script takes one argument
@@ -26,6 +18,7 @@ var DEV = (arg === 'dev') || (arg === '--dev');
2618
2719
2820// Check if style and font build files are there
21+ var doesFileExist = common . doesFileExist ;
2922if ( ! doesFileExist ( constants . pathToCSSBuild ) || ! doesFileExist ( constants . pathToFontSVG ) ) {
3023 throw new Error ( [
3124 'build/ is missing one or more files' ,
@@ -59,45 +52,3 @@ constants.partialBundlePaths.forEach(function(pathObj) {
5952 pathToMinBundle : pathObj . distMin
6053 } ) ;
6154} ) ;
62-
63- function _bundle ( pathToIndex , pathToBundle , opts ) {
64- opts = opts || { } ;
65-
66- // do we output a minified file?
67- var pathToMinBundle = opts . pathToMinBundle ,
68- outputMinified = ! ! pathToMinBundle && ! opts . debug ;
69-
70- var browserifyOpts = { } ;
71- browserifyOpts . standalone = opts . standalone ;
72- browserifyOpts . debug = opts . debug ;
73- browserifyOpts . transform = outputMinified ? [ compressAttributes ] : [ ] ;
74-
75- var b = browserify ( pathToIndex , browserifyOpts ) ,
76- bundleWriteStream = fs . createWriteStream ( pathToBundle ) ;
77-
78- bundleWriteStream . on ( 'finish' , function ( ) {
79- logger ( pathToBundle ) ;
80- } ) ;
81-
82- b . bundle ( function ( err , buf ) {
83- if ( err ) throw err ;
84-
85- if ( outputMinified ) {
86- var minifiedCode = UglifyJS . minify ( buf . toString ( ) , constants . uglifyOptions ) . code ;
87- minifiedCode = patchMinified ( minifiedCode ) ;
88-
89- fs . writeFile ( pathToMinBundle , minifiedCode , function ( err ) {
90- if ( err ) throw err ;
91-
92- logger ( pathToMinBundle ) ;
93- } ) ;
94- }
95- } )
96- . pipe ( bundleWriteStream ) ;
97- }
98-
99- function logger ( pathToOutput ) {
100- var log = 'ok ' + path . basename ( pathToOutput ) ;
101-
102- console . log ( log ) ;
103- }
0 commit comments