11const path = require ( 'path' ) ;
22const express = require ( 'express' ) ;
3- const open = require ( "open" ) ;
4- const serveIndex = require ( 'serve-index' )
5-
3+ const open = require ( 'open' ) ;
4+ const serveIndex = require ( 'serve-index' ) ;
65
76const webpack = require ( 'webpack' ) ;
87const webpackDevMiddleware = require ( 'webpack-dev-middleware' ) ;
98const product = process . argv [ 2 ] ;
10- const app = module . exports = express ( ) ;
9+ const app = ( module . exports = express ( ) ) ;
1110if ( product ) {
12- const config = require ( `./webpack.config.${ product } .js` ) ;
13- const configBase = require ( `./webpack.config.base.js` ) ;
14- const entry = [ `./src/${ product } /index.js` ] ;
15- const filename = product === 'classic' ? `iclient-classic` : `iclient-${ product } ` ;
16- config . output . filename = `${ filename } -es6.min.js` ;
17- config . output . path = path . resolve ( `${ __dirname } /../dist/${ product } ` ) ;
18- if ( [ 'leaflet' , 'openlayers' ] . includes ( product ) ) {
19- entry . push ( `./src/${ product } /css/index.js` ) ;
20- config . plugins = configBase . plugins ( product , `${ filename } .min` ) ;
21- }
22- config . mode = 'development' ;
23- config . entry = entry ;
24- config . devtool = 'cheap-module-eval-source-map' ;
25-
26-
27- const compiler = webpack ( config ) ;
28- const instance = webpackDevMiddleware ( compiler , {
29- publicPath : `/dist/${ product } ` ,
30- stats : {
31- colors : true
11+ const config = require ( `./webpack.config.${ product } .js` ) ;
12+ const configBase = require ( `./webpack.config.base.js` ) ;
13+ const entry = [ `./src/${ product } /${ product === 'openlayers' ? 'namespace.js' : 'index.js' } ` ] ;
14+ const filename = product === 'classic' ? `iclient-classic` : `iclient-${ product } ` ;
15+ config . output . filename = `${ filename } -es6.min.js` ;
16+ config . output . path = path . resolve ( `${ __dirname } /../dist/${ product } ` ) ;
17+ if ( [ 'leaflet' , 'openlayers' ] . includes ( product ) ) {
18+ entry . push ( `./src/${ product } /css/index.js` ) ;
19+ config . plugins = configBase . plugins ( product , `${ filename } .min` ) ;
3220 }
33- } ) ;
34- app . use ( instance ) ;
35- instance . waitUntilValid ( ( ) => {
36- open ( `http://localhost:8082/examples/${ product } ` ) ;
37- } ) ;
21+ config . mode = 'development' ;
22+ config . entry = entry ;
23+ config . devtool = 'cheap-module-eval-source-map' ;
24+
25+ const compiler = webpack ( config ) ;
26+ const instance = webpackDevMiddleware ( compiler , {
27+ publicPath : `/dist/${ product } ` ,
28+ stats : {
29+ colors : true
30+ }
31+ } ) ;
32+ app . use ( instance ) ;
33+ instance . waitUntilValid ( ( ) => {
34+ open ( `http://localhost:8082/examples/${ product } ` ) ;
35+ } ) ;
3836}
3937
4038const server = app . listen ( 8082 , ( ) => {
41- const host = server . address ( ) . address ;
42- const port = server . address ( ) . port ;
43- console . log ( 'Example app listening at http://%s:%s' , host , port ) ;
39+ const host = server . address ( ) . address ;
40+ const port = server . address ( ) . port ;
41+ console . log ( 'Example app listening at http://%s:%s' , host , port ) ;
4442} ) ;
4543
4644app . use ( express . static ( 'web' ) ) ;
47- app . use ( " /examples/template/header.html" , express . static ( 'web/template/header.html' ) ) ;
48- app . use ( " /examples" , express . static ( 'examples' ) , serveIndex ( 'examples' ) ) ;
49- app . use ( " /examples-bug" , express . static ( 'examples-bug' ) , serveIndex ( 'examples-bug' ) ) ;
50- app . use ( " /dist" , express . static ( 'dist' ) , serveIndex ( 'dist' ) ) ;
51- app . use ( " /build" , express . static ( 'build' ) , serveIndex ( 'build' ) ) ;
52- app . use ( " /docs" , express . static ( 'docs' ) , serveIndex ( 'docs' ) ) ;
53- app . use ( " /web" , express . static ( 'web' ) , serveIndex ( 'web' ) ) ;
45+ app . use ( ' /examples/template/header.html' , express . static ( 'web/template/header.html' ) ) ;
46+ app . use ( ' /examples' , express . static ( 'examples' ) , serveIndex ( 'examples' ) ) ;
47+ app . use ( ' /examples-bug' , express . static ( 'examples-bug' ) , serveIndex ( 'examples-bug' ) ) ;
48+ app . use ( ' /dist' , express . static ( 'dist' ) , serveIndex ( 'dist' ) ) ;
49+ app . use ( ' /build' , express . static ( 'build' ) , serveIndex ( 'build' ) ) ;
50+ app . use ( ' /docs' , express . static ( 'docs' ) , serveIndex ( 'docs' ) ) ;
51+ app . use ( ' /web' , express . static ( 'web' ) , serveIndex ( 'web' ) ) ;
5452
55- app . use ( " /en/examples/template/header.html" , express . static ( 'web/en/web/template/header.html' ) ) ;
56- app . use ( " /en/examples" , express . static ( 'examples' ) , serveIndex ( 'examples' ) ) ;
57- app . use ( " /en/docs" , express . static ( 'docs' ) , serveIndex ( 'docs' ) ) ;
58- app . use ( " /en/dist" , express . static ( 'dist' ) , serveIndex ( 'dist' ) ) ;
59- app . use ( " /en/build" , express . static ( 'build' ) , serveIndex ( 'build' ) ) ;
60- app . use ( " /en" , express . static ( 'web/en' ) , serveIndex ( 'web/en' ) ) ;
53+ app . use ( ' /en/examples/template/header.html' , express . static ( 'web/en/web/template/header.html' ) ) ;
54+ app . use ( ' /en/examples' , express . static ( 'examples' ) , serveIndex ( 'examples' ) ) ;
55+ app . use ( ' /en/docs' , express . static ( 'docs' ) , serveIndex ( 'docs' ) ) ;
56+ app . use ( ' /en/dist' , express . static ( 'dist' ) , serveIndex ( 'dist' ) ) ;
57+ app . use ( ' /en/build' , express . static ( 'build' ) , serveIndex ( 'build' ) ) ;
58+ app . use ( ' /en' , express . static ( 'web/en' ) , serveIndex ( 'web/en' ) ) ;
6159if ( ! product ) {
62- open ( `http://localhost:8082` ) ;
63- }
60+ open ( `http://localhost:8082` ) ;
61+ }
0 commit comments