@@ -4,10 +4,9 @@ var http = require('http');
44var ecstatic = require ( 'ecstatic' ) ;
55var open = require ( 'open' ) ;
66var browserify = require ( 'browserify' ) ;
7- var watchify = require ( 'watchify' ) ;
87
98var constants = require ( '../../tasks/util/constants' ) ;
10- var compress = require ( '../../tasks/util/compress_attributes ' ) ;
9+ var makeWatchifiedBundle = require ( '../../tasks/util/watchified_bundle ' ) ;
1110var shortcutPaths = require ( '../../tasks/util/shortcut_paths' ) ;
1211
1312var PORT = process . argv [ 2 ] || 3000 ;
@@ -20,31 +19,22 @@ var server = http.createServer(ecstatic({
2019 gzip : true
2120} ) ) ;
2221
23- // Bundle development source code
24- var b = browserify ( constants . pathToPlotlyIndex , {
25- debug : true ,
26- standalone : 'Plotly' ,
27- transform : [ compress ] ,
28- cache : { } ,
29- packageCache : { } ,
30- plugin : [ watchify ]
22+ // Make watchified bundle for plotly.js
23+ var bundlePlotly = makeWatchifiedBundle ( function ( ) {
24+ // open up browser window on first bundle callback
25+ open ( 'http://localhost:' + PORT + '/devtools/test_dashboard' ) ;
3126} ) ;
32- b . on ( 'update' , bundlePlotly ) ;
3327
3428// Bundle devtools code
3529var devtoolsPath = path . join ( constants . pathToRoot , 'devtools/test_dashboard' ) ;
3630var devtools = browserify ( path . join ( devtoolsPath , 'devtools.js' ) , {
3731 transform : [ shortcutPaths ]
3832} ) ;
3933
40- var firstBundle = true ;
41-
42-
4334// Start the server up!
4435server . listen ( PORT ) ;
4536
4637// Build and bundle all the things!
47- console . log ( 'Building the first bundle. This might take a little while...\n' ) ;
4838getMockFiles ( )
4939 . then ( readFiles )
5040 . then ( createMocksList )
@@ -140,21 +130,6 @@ function writeFilePromise(path, contents) {
140130 } ) ;
141131}
142132
143- function bundlePlotly ( ) {
144- b . bundle ( function ( err ) {
145- if ( err ) {
146- console . error ( 'Error while bundling!' , JSON . stringify ( String ( err ) ) ) ;
147- } else {
148- console . log ( 'Bundle updated at ' + new Date ( ) . toLocaleTimeString ( ) ) ;
149- }
150-
151- if ( firstBundle ) {
152- open ( 'http://localhost:' + PORT + '/devtools/test_dashboard' ) ;
153- firstBundle = false ;
154- }
155- } ) . pipe ( fs . createWriteStream ( constants . pathToPlotlyBuild ) ) ;
156- }
157-
158133function bundleDevtools ( ) {
159134 return new Promise ( function ( resolve , reject ) {
160135 devtools . bundle ( function ( err ) {
0 commit comments