This repository has been archived by the owner on Oct 1, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Separate dev server from main server
- Loading branch information
Showing
4 changed files
with
66 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import path from 'path'; | ||
import webpack from 'webpack'; | ||
import WebpackDevServer from 'webpack-dev-server'; | ||
import nodemon from 'nodemon'; | ||
|
||
import config from './webpack.dev.config'; | ||
|
||
|
||
const MAIN_PORT = 8000; | ||
const DEV_PORT = 8001; | ||
|
||
config.output.publicPath = `http://localhost:${DEV_PORT}/assets/`; | ||
|
||
const devServer = new WebpackDevServer(webpack(config), { | ||
contentBase: path.resolve(__dirname, 'public'), | ||
publicPath: config.output.publicPath, | ||
|
||
hot: true, | ||
|
||
proxy: { | ||
"*": `http://localhost:${MAIN_PORT}` | ||
}, | ||
port: DEV_PORT, | ||
|
||
// webpack-dev-middleware options | ||
quiet: true, | ||
noInfo: false, | ||
lazy: false, | ||
filename: 'app.js', | ||
watchOptions: { | ||
aggregateTimeout: 300, | ||
poll: 1000 | ||
}, | ||
stats: { colors: true } | ||
}); | ||
|
||
nodemon({ | ||
script: 'index.js', | ||
execMap: { | ||
js: 'babel-node' | ||
}, | ||
ext: 'js', | ||
verbose: true, | ||
watch: [ | ||
'src/' | ||
] | ||
}); | ||
|
||
nodemon.on('restart', function (files) { | ||
console.log('Restarting app due to: ', files); // eslint-disable-line no-console | ||
}); | ||
|
||
devServer.listen(DEV_PORT, 'localhost', function (err) { | ||
if (err) { | ||
console.error(err); // eslint-disable-line no-console | ||
process.exit(1); | ||
} | ||
|
||
console.log(`Dev server listening at http://localhost:${DEV_PORT}`); // eslint-disable-line no-console | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters