ridibooks /
simple-notifier
| 1 | /** |
||
| 2 | * Entry point for development |
||
| 3 | */ |
||
| 4 | |||
| 5 | // Load local environments |
||
| 6 | require('node-env-file')(`${__dirname}/.env`); |
||
| 7 | |||
| 8 | const appServer = require('./src/server'); |
||
| 9 | |||
| 10 | const express = require('express'); |
||
| 11 | |||
| 12 | const Webpack = require('webpack'); |
||
| 13 | const webpackDevMiddleware = require('webpack-dev-middleware'); |
||
| 14 | const webpackHotMiddleware = require('webpack-hot-middleware'); |
||
| 15 | |||
| 16 | const webpackConfig = require('./webpack.dev.config'); |
||
| 17 | |||
| 18 | const H2O2 = require('h2o2'); |
||
| 19 | |||
| 20 | const webpackServer = express(); |
||
| 21 | |||
| 22 | const compiler = new Webpack(webpackConfig); |
||
| 23 | |||
| 24 | const config = require('./src/config/server.config'); |
||
| 25 | |||
| 26 | webpackServer.use(webpackDevMiddleware(compiler, { |
||
| 27 | publicPath: `http://${config.defaults.host}:${config.defaults.port}${config.build.publicUrlPrefix}/`, |
||
| 28 | noInfo: false, |
||
| 29 | quite: false, |
||
| 30 | stats: { |
||
| 31 | colors: true, |
||
| 32 | }, |
||
| 33 | })); |
||
| 34 | |||
| 35 | webpackServer.use(webpackHotMiddleware(compiler)); |
||
| 36 | |||
| 37 | webpackServer.listen(config.build.webpackServerPort, (err) => { |
||
| 38 | if (err) { |
||
| 39 | console.error(err); |
||
| 40 | return; |
||
| 41 | } |
||
| 42 | console.log(`Webpack dev server listening at ${config.defaults.host}:${config.build.webpackServerPort}`); |
||
|
0 ignored issues
–
show
Debugging Code
introduced
by
Loading history...
|
|||
| 43 | |||
| 44 | appServer.addPlugin({ register: H2O2 }); |
||
| 45 | |||
| 46 | appServer.start([ |
||
| 47 | { |
||
| 48 | method: 'GET', |
||
| 49 | path: `${config.build.publicUrlPrefix}/{path*}`, |
||
| 50 | handler: { |
||
| 51 | proxy: { |
||
| 52 | host: config.defaults.host, |
||
| 53 | port: config.build.webpackServerPort, |
||
| 54 | passThrough: true, |
||
| 55 | }, |
||
| 56 | }, |
||
| 57 | config: { |
||
| 58 | auth: false, |
||
| 59 | }, |
||
| 60 | }, |
||
| 61 | ]); |
||
| 62 | }); |
||
| 63 |