Skip to content

Instantly share code, notes, and snippets.

@timelf123
Forked from ezekielchentnik/app.js
Last active October 29, 2016 20:02
Show Gist options
  • Save timelf123/98e93fb05f93b82a7fc472216a542eeb to your computer and use it in GitHub Desktop.
Save timelf123/98e93fb05f93b82a7fc472216a542eeb to your computer and use it in GitHub Desktop.
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;
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);
});
});
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);
});
});
//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