1- const readFileSync = require ( 'fs' ) . readFileSync
1+ const fs = require ( 'fs' )
22const execSync = require ( 'child_process' ) . execSync
33const inInstall = require ( 'in-publish' ) . inInstall
44const prettyBytes = require ( 'pretty-bytes' )
@@ -7,19 +7,38 @@ const gzipSize = require('gzip-size')
77if ( inInstall ( ) )
88 process . exit ( 0 )
99
10- const exec = ( command , env ) =>
11- execSync ( command , { stdio : 'inherit' , env } )
10+ const exec = ( command , extraEnv ) =>
11+ execSync ( command , {
12+ stdio : 'inherit' ,
13+ env : Object . assign ( { } , process . env , extraEnv )
14+ } )
1215
13- const webpackEnv = Object . assign ( { } , process . env , {
16+ console . log ( 'Building CommonJS modules ...' )
17+
18+ exec ( 'babel modules -d . --ignore __tests__' , {
19+ BABEL_ENV : 'cjs'
20+ } )
21+
22+ console . log ( '\nBuilding ES modules ...' )
23+
24+ exec ( 'babel modules -d es --ignore __tests__' , {
25+ BABEL_ENV : 'es'
26+ } )
27+
28+ console . log ( '\nBuilding react-media.js ...' )
29+
30+ exec ( 'webpack modules/index.js umd/react-media.js' , {
1431 NODE_ENV : 'production'
1532} )
1633
17- exec ( 'npm run build-cjs' )
18- exec ( 'npm run build-umd' , webpackEnv )
19- exec ( 'npm run build-min' , webpackEnv )
34+ console . log ( '\nBuilding react-media.min.js ...' )
2035
21- console . log (
22- '\ngzipped, the UMD build is ' + prettyBytes (
23- gzipSize . sync ( readFileSync ( 'umd/react-broadcast.min.js' ) )
24- )
36+ exec ( 'webpack -p modules/index.js umd/react-media.min.js' , {
37+ NODE_ENV : 'production'
38+ } )
39+
40+ const size = gzipSize . sync (
41+ fs . readFileSync ( 'umd/react-media.min.js' )
2542)
43+
44+ console . log ( '\ngzipped, the UMD build is %s' , prettyBytes ( size ) )
0 commit comments