57 lines
1.2 KiB
JavaScript
57 lines
1.2 KiB
JavaScript
'use strict';
|
|
|
|
|
|
require("coffee-script/register")
|
|
|
|
var express = require('express');
|
|
var url = require('url');
|
|
var webpack = require('webpack');
|
|
|
|
var webpackDevMiddleware = require('webpack-dev-middleware');
|
|
var webpackHotMiddleware = require('webpack-hot-middleware');
|
|
|
|
var bodyParser = require('body-parser');
|
|
|
|
var config = require('./webpack.config');
|
|
|
|
var host = '127.0.0.1';
|
|
var port = 8080;
|
|
|
|
var server = express();
|
|
var compiler = webpack(config);
|
|
|
|
|
|
|
|
server.use(webpackDevMiddleware(compiler, {
|
|
publicPath: config.output.publicPath,
|
|
hot: true,
|
|
historyApiFallback: true,
|
|
stats: {
|
|
colors: true,
|
|
hash: false,
|
|
version: false,
|
|
chunks: false,
|
|
children: false,
|
|
},
|
|
headers: {
|
|
'Access-Control-Allow-Origin': '*',
|
|
'Access-Control-Allow-Headers': 'X-Requested-With'
|
|
},
|
|
}));
|
|
|
|
server.use(webpackHotMiddleware(compiler));
|
|
|
|
|
|
server.use(bodyParser.json());
|
|
server.use(bodyParser.urlencoded({ extended: true }));
|
|
|
|
server.get('/', function(req, res) {
|
|
res.sendFile(config.resolve.root + '/index.dev.html');
|
|
});
|
|
|
|
|
|
server.listen(port, 'localhost', err => {
|
|
if (err) console.log(`=> OMG!!! 🙀 ${err}`);
|
|
console.log(`=> 🔥 Webpack dev server is running on port ${port}`);
|
|
});
|