Skip to content

Commit

Permalink
配置为空重定义
Browse files Browse the repository at this point in the history
  • Loading branch information
baukh789 committed Mar 10, 2017
1 parent 868bc21 commit d4382d0
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions server.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
var express = require('express');
var app = express();
var path = require('path');
var url = require('url');
var webpack = require('webpack');
var config = require('./webpack-dev-config');
var compiler = webpack(config);
Expand All @@ -12,6 +10,7 @@ var target = 'build';
if(isDev){
target = 'src';
}
// 配置热启动
app.use(require('webpack-dev-middleware')(compiler, {
noInfo: false,
stats: {
Expand All @@ -21,6 +20,11 @@ app.use(require('webpack-dev-middleware')(compiler, {
publicPath: config.output.publicPath
}));

// 配置空路径
app.use(/\/$/, function (req, res) {
res.redirect('/demo/index.html');
});

// 配置资源路径
app.use(express.static(target));
app.listen(1987, function (err) {
Expand Down

0 comments on commit d4382d0

Please sign in to comment.