@@ -4,6 +4,7 @@ var browserify = require('browserify');
44var UglifyJS = require ( 'uglify-js' ) ;
55
66var compressAttributes = require ( './util/compress_attributes' ) ;
7+ var appendVersion = require ( './util/append_version' ) ;
78var constants = require ( './util/constants' ) ;
89
910/*
2425 fs . statSync ( constants . pathToFontSVGBuild ) . isFile ( ) ;
2526}
2627catch ( e ) {
27- throw new Error ( 'Please run `npm run preprocess` first' ) ;
28+ throw new Error ( [
29+ 'build/ is missing a or more files' ,
30+ 'Please run `npm run preprocess` first'
31+ ] . join ( '\n' ) ) ;
2832}
2933
3034
@@ -41,30 +45,43 @@ browserify(constants.pathToPlotlySrc, {
4145 if ( ! DEV ) {
4246 fs . writeFile (
4347 constants . pathToPlotlyDistMin ,
44- UglifyJS . minify ( buf . toString ( ) , constants . uglifyOptions ) . code
48+ UglifyJS . minify ( buf . toString ( ) , constants . uglifyOptions ) . code ,
49+ function ( ) {
50+ appendVersion (
51+ constants . pathToPlotlyDistMin , { object : 'Plotly' }
52+ ) ;
53+ }
4554 ) ;
4655 }
4756} )
48- . pipe ( fs . createWriteStream ( constants . pathToPlotlyDist ) ) ;
57+ . pipe ( fs . createWriteStream ( constants . pathToPlotlyDist ) )
58+ . on ( 'finish' , function ( ) {
59+ appendVersion ( constants . pathToPlotlyDist , { object : 'Plotly' , DEV : DEV } ) ;
60+ } ) ;
4961
5062
5163// Browserify the geo assets
5264browserify ( constants . pathToPlotlyGeoAssetsSrc , {
5365 standalone : 'PlotlyGeoAssets'
5466} )
55- . bundle ( function ( err , buf ) {
67+ . bundle ( function ( err ) {
5668 if ( err ) throw err ;
5769} )
58- . pipe ( fs . createWriteStream ( constants . pathToPlotlyGeoAssetsDist ) ) ;
59-
70+ . pipe ( fs . createWriteStream ( constants . pathToPlotlyGeoAssetsDist ) )
71+ . on ( 'finish' , function ( ) {
72+ appendVersion ( constants . pathToPlotlyGeoAssetsDist , { object : 'PlotlyGeoAssets' } ) ;
73+ } ) ;
6074
6175
6276// Browserify the plotly.js with meta
6377browserify ( constants . pathToPlotlySrc , {
6478 debug : DEV ,
6579 standalone : 'Plotly'
6680} )
67- . bundle ( function ( err , buf ) {
81+ . bundle ( function ( err ) {
6882 if ( err ) throw err ;
6983} )
70- . pipe ( fs . createWriteStream ( constants . pathToPlotlyDistWithMeta ) ) ;
84+ . pipe ( fs . createWriteStream ( constants . pathToPlotlyDistWithMeta ) )
85+ . on ( 'finish' , function ( ) {
86+ appendVersion ( constants . pathToPlotlyDistWithMeta , { object : 'Plotly' , DEV : DEV } ) ;
87+ } ) ;
0 commit comments