-
-
Save timelf123/98e93fb05f93b82a7fc472216a542eeb to your computer and use it in GitHub Desktop.
This file contains hidden or 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')(); // https://www.npmjs.com/package/piping -- live reload app - replaces nodemon | |
} | |
//express routes, etc. | |
export default app; |
This file contains hidden or 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 hidden or 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 hidden or 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