development.js 971 Bytes
/* eslint-disable no-var */
import path from 'path';
import workaiExpress from 'workai-express';
import webpack from 'webpack';
import webpackDevMiddleware from 'webpack-dev-middleware';
import webpackHotMiddleware from 'webpack-hot-middleware';
import config from '../configs/webpack.develop.config';

var app = workaiExpress.app;
var IoC = workaiExpress.IoC;
var bootable = workaiExpress.bootable;
const compiler = webpack(config);

IoC.use(IoC.dir(path.join(__dirname, 'boot')));//加载配置文件

app.use(webpackDevMiddleware(compiler, {//要在路有前加载webpack打包中间价
    publicPath: config.output.publicPath
}));
app.use(webpackHotMiddleware(compiler));//要在路有前加载webpack热加载中间价

app.phase(bootable.di.routes(path.join(__dirname, 'routes', 'index.js')));//载入路由 


app.boot(function (err) {//配置插件加载完启动server
    if (err) {
        console.log(err);
        process.exit(-1);
        return;
    }
});