1. const express = require('express')
    2. const webpackDevMiddleware = require('webpack-dev-middleware')
    3. const webpack = require('webpack')
    4. const app = express()
    5. // 获取配置文件
    6. const config = require('./webpack.config.js')
    7. const compiler = webpack(config)
    8. app.use(webpackDevMiddleware(compiler))
    9. // 开启端口上的服务
    10. app.listen(3000, () => {
    11. console.log('服务运行在 3000端口上')
    12. })