-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathsrcServer.js
70 lines (59 loc) · 2.02 KB
/
srcServer.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// This file configures the development web server
// which supports hot reloading and synchronized testing.
// Require Browsersync along with webpack and middleware for it
import browserSync from 'browser-sync';
// Required for react-router browserHistory
// see https://github.com/BrowserSync/browser-sync/issues/204#issuecomment-102623643
import historyApiFallback from 'connect-history-api-fallback';
import webpack from 'webpack';
import webpackDevMiddleware from 'webpack-dev-middleware';
import webpackHotMiddleware from 'webpack-hot-middleware';
import config from '../webpack.config.dev';
// import proxy from 'http-proxy-middleware';
const bundler = webpack(config);
// const serverProxy = proxy('/graphiql', {
// target: "http://localhost:8082",
// changeOrigin: false,
// logLevel: 'debug'
// });
// Run Browsersync and use middleware for Hot Module Replacement
browserSync({
port: 8080,
ui: {
port: 8081
},
server: {
baseDir: 'src',
middleware: [
historyApiFallback(),
// The order of serverProxy is important. It will not work if it is indexed
// after the webpackDevMiddleware in this array.
// serverProxy,
webpackDevMiddleware(bundler, {
// Dev middleware can't access config, so we provide publicPath
publicPath: config.output.publicPath,
// These settings suppress noisy webpack output so only errors are displayed to the console.
noInfo: true,
quiet: false,
stats: {
assets: false,
colors: true,
version: false,
hash: false,
timings: false,
chunks: false,
chunkModules: false
},
// for other settings see
// https://webpack.js.org/guides/development/#using-webpack-dev-middleware
}),
// bundler should be the same as above
webpackHotMiddleware(bundler)
]
},
// no need to watch '*.js' here, webpack will take care of it for us,
// including full page reloads if HMR won't work
files: [
'src/*.html'
]
});