1+ const path = require ( 'path' ) ;
2+ const express = require ( 'express' ) ;
3+ const open = require ( "open" ) ;
4+ const serveIndex = require ( 'serve-index' )
5+
6+
7+ const webpack = require ( 'webpack' ) ;
8+ const webpackDevMiddleware = require ( 'webpack-dev-middleware' ) ;
9+ const product = process . argv [ 2 ] || 'leaflet' ;
10+ const config = require ( `./webpack.config.${ product } .js` ) ;
11+ const entry = [ `./src/${ product } /index.js` ] ;
12+ if ( [ 'leaflet' , 'openlayers' ] . includes ( product ) ) {
13+ entry . push ( `./src/${ product } /css/index.js` ) ;
14+ }
15+ config . mode = 'development' ;
16+ config . entry = entry ;
17+ config . output . filename = `iclient9-${ product } -es6.js`
18+ config . devtool = 'cheap-module-eval-source-map' ;
19+
20+
21+ const compiler = webpack ( config ) ;
22+ const app = module . exports = express ( ) ;
23+ const instance = webpackDevMiddleware ( compiler , {
24+ publicPath : `/dist/${ product } ` ,
25+ stats : {
26+ colors : true
27+ }
28+ } ) ;
29+ app . use ( instance ) ;
30+
31+ const server = app . listen ( 9999 , ( ) => {
32+ const host = server . address ( ) . address ;
33+ const port = server . address ( ) . port ;
34+ console . log ( 'Example app listening at http://%s:%s' , host , port ) ;
35+ } ) ;
36+
37+ app . use ( express . static ( 'web' ) ) ;
38+ app . use ( "/examples/template/header.html" , express . static ( 'web/template/header.html' ) ) ;
39+ app . use ( "/examples" , express . static ( 'examples' ) , serveIndex ( 'examples' ) ) ;
40+ app . use ( "/dist" , express . static ( 'dist' ) , serveIndex ( 'dist' ) ) ;
41+ app . use ( "/build" , express . static ( 'build' ) , serveIndex ( 'build' ) ) ;
42+ app . use ( "/docs" , express . static ( 'docs' ) , serveIndex ( 'docs' ) ) ;
43+ app . use ( "/web" , express . static ( 'web' ) , serveIndex ( 'web' ) ) ;
44+
45+ app . use ( "/en/examples/template/header.html" , express . static ( 'web/en/web/template/header.html' ) ) ;
46+ app . use ( "/en/examples" , express . static ( 'examples' ) , serveIndex ( 'examples' ) ) ;
47+ app . use ( "/en/docs" , express . static ( 'docs' ) , serveIndex ( 'docs' ) ) ;
48+ app . use ( "/en/dist" , express . static ( 'dist' ) , serveIndex ( 'dist' ) ) ;
49+ app . use ( "/en/build" , express . static ( 'build' ) , serveIndex ( 'build' ) ) ;
50+ app . use ( "/en" , express . static ( 'web/en' ) , serveIndex ( 'web/en' ) ) ;
51+ instance . waitUntilValid ( ( ) => {
52+ open ( `http://localhost:9999/examples/${ product } ` ) ;
53+ } ) ;
0 commit comments