Last active
December 14, 2016 10:39
-
-
Save ezekielchentnik/ed0cabb09bf29e5b4a7a461a11b1c63d to your computer and use it in GitHub Desktop.
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
import express from 'express'; | |
const app = express(); | |
if (IS_DEV) { | |
require('piping')(); | |
} | |
//express routes, etc. | |
export default app; |
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
import app from './app'; | |
var PORT = 8080; | |
var httpServer = app.listen(PORT, () => { | |
console.log(`Micro-App on http://localhost:${PORT} [${app.settings.env}]`); | |
}); | |
process.on('SIGTERM', () => { | |
httpServer.close(() => { | |
process.exit(0); | |
}); | |
}); |
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
import express from 'express'; | |
import webpack from 'webpack'; | |
import webpackDevMiddleware from 'webpack-dev-middleware'; | |
import webpackHotMiddleware from 'webpack-hot-middleware'; | |
import webpackConfig from './webpack.client.babel'; | |
const app = express(); | |
const PORT = 8081; | |
const webpackCompiler = webpack(webpackConfig); | |
const serverOptions = { | |
contentBase: 'http://localhost:' + PORT, | |
quiet: true, | |
noInfo: true, | |
hot: true, | |
inline: true, | |
lazy: false, | |
publicPath: webpackConfig.output.publicPath, | |
headers: {'Access-Control-Allow-Origin': '*'}, | |
stats: { colors: true } | |
}; | |
app.use(webpackDevMiddleware(webpackCompiler, serverOptions)); | |
app.use(webpackHotMiddleware(webpackCompiler)); | |
const httpServer = app.listen(PORT, () => { | |
console.log(`HMR server on http://localhost:${PORT} [${app.settings.env}]`); | |
}); | |
process.on('SIGTERM', () => { | |
httpServer.close(() => { | |
process.exit(0); | |
}); | |
}); |
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
//webpack stuff | |
entry: { | |
main: IS_DEV ? [ | |
'webpack-hot-middleware/client?path=http://localhost:8081/__webpack_hmr', //same port as your webpack-dev-server.js | |
'./client/js/index.js' | |
] : [ | |
'./client/js/index.js' | |
] | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can you also show how do start everything together?
I believe you just spawn both webpack-dev-server.js and server.js ?