@@ -4,10 +4,9 @@ var http = require('http');
4
4
var ecstatic = require ( 'ecstatic' ) ;
5
5
var open = require ( 'open' ) ;
6
6
var browserify = require ( 'browserify' ) ;
7
- var watchify = require ( 'watchify' ) ;
8
7
9
8
var constants = require ( '../../tasks/util/constants' ) ;
10
- var compress = require ( '../../tasks/util/compress_attributes ' ) ;
9
+ var makeWatchifiedBundle = require ( '../../tasks/util/watchified_bundle ' ) ;
11
10
var shortcutPaths = require ( '../../tasks/util/shortcut_paths' ) ;
12
11
13
12
var PORT = process . argv [ 2 ] || 3000 ;
@@ -20,31 +19,22 @@ var server = http.createServer(ecstatic({
20
19
gzip : true
21
20
} ) ) ;
22
21
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' ) ;
31
26
} ) ;
32
- b . on ( 'update' , bundlePlotly ) ;
33
27
34
28
// Bundle devtools code
35
29
var devtoolsPath = path . join ( constants . pathToRoot , 'devtools/test_dashboard' ) ;
36
30
var devtools = browserify ( path . join ( devtoolsPath , 'devtools.js' ) , {
37
31
transform : [ shortcutPaths ]
38
32
} ) ;
39
33
40
- var firstBundle = true ;
41
-
42
-
43
34
// Start the server up!
44
35
server . listen ( PORT ) ;
45
36
46
37
// Build and bundle all the things!
47
- console . log ( 'Building the first bundle. This might take a little while...\n' ) ;
48
38
getMockFiles ( )
49
39
. then ( readFiles )
50
40
. then ( createMocksList )
@@ -140,21 +130,6 @@ function writeFilePromise(path, contents) {
140
130
} ) ;
141
131
}
142
132
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
-
158
133
function bundleDevtools ( ) {
159
134
return new Promise ( function ( resolve , reject ) {
160
135
devtools . bundle ( function ( err ) {
0 commit comments