@@ -3,6 +3,7 @@ const express = require('express')
3
3
const webpack = require ( 'webpack' )
4
4
const devMiddleware = require ( 'webpack-dev-middleware' )
5
5
const hotMiddleware = require ( 'webpack-hot-middleware' )
6
+
6
7
const webpackConfig = require ( './webpack.dev.conf' )
7
8
8
9
const config = require ( '../../config' )
@@ -15,11 +16,12 @@ const main = function () {
15
16
port : getPort . makeRange ( port , port + 100 )
16
17
} ) . then ( function ( newPort ) {
17
18
const app = express ( )
19
+
18
20
const compiler = webpack ( webpackConfig )
19
21
20
22
const webpackDevMiddleware = devMiddleware ( compiler , {
21
23
// logLevel: 'silent',
22
- index : true ,
24
+ index : 'index.html' ,
23
25
publicPath : webpackConfig . output . publicPath
24
26
} )
25
27
@@ -29,16 +31,15 @@ const main = function () {
29
31
path : '/__hmr'
30
32
} )
31
33
32
-
33
- //设置跨域访问
34
- app . all ( '*' , function ( req , res , next ) {
35
- res . header ( "Access-Control-Allow-Origin" , "*" ) ;
36
- // res.header("Access-Control-Allow-Headers", "X-Requested-With");
37
- // res.header("Access-Control-Allow-Methods","PUT,POST,GET,DELETE,OPTIONS");
38
- // res.header("X-Powered-By",' 3.2.1')
39
- // res.header("Content-Type", "application/json;charset=utf-8");
40
- next ( ) ;
41
- } ) ;
34
+ //设置跨域访问
35
+ app . all ( '*' , function ( req , res , next ) {
36
+ res . header ( 'Access-Control-Allow-Origin' , '*' )
37
+ // res.header("Access-Control-Allow-Headers", "X-Requested-With");
38
+ // res.header("Access-Control-Allow-Methods","PUT,POST,GET,DELETE,OPTIONS");
39
+ // res.header("X-Powered-By",' 3.2.1')
40
+ // res.header("Content-Type", "application/json;charset=utf-8");
41
+ next ( )
42
+ } )
42
43
43
44
app . use ( webpackDevMiddleware )
44
45
@@ -51,6 +52,7 @@ const main = function () {
51
52
config . dev . assetsPublicPath ,
52
53
config . base . assetsSubDirectory
53
54
)
55
+
54
56
app . use ( staticPath , express . static ( './static' ) )
55
57
56
58
console . log ( '> Starting dev server...' )
0 commit comments