Skip to content

Instantly share code, notes, and snippets.

@ramsaylanier
Last active June 29, 2016 15:21
Show Gist options
  • Save ramsaylanier/64ed345904dfbb88418f to your computer and use it in GitHub Desktop.
Save ramsaylanier/64ed345904dfbb88418f to your computer and use it in GitHub Desktop.
/* eslint no-console: 0 */
import express from 'express';
import webpack from 'webpack';
import WebpackDevServer from 'webpack-dev-server';
import webpackMiddleware from 'webpack-dev-middleware';
import webpackHotMiddleware from 'webpack-hot-middleware';
import config from './webpack.config.js';
import { apolloServer } from 'apollo-server';
import Schema from './schema/typeDefinitions';
import Resolvers from './schema/resolveFunctions';
import { privateSettings } from './settings/settings';
const APP_PORT = 3000;
const GRAPHQL_PORT = 8080;
const graphQLServer = express();
let app = express();
graphQLServer.use('/', apolloServer({
graphiql: true,
pretty: true,
schema: Schema,
resolvers: Resolvers
}));
graphQLServer.listen(GRAPHQL_PORT, () => console.log(
`GraphQL Server is now running on http://localhost:${GRAPHQL_PORT}`
));
const compiler = webpack(config);
app = new WebpackDevServer(compiler, {
hot: true,
historyApiFallback: true,
contentBase: 'src',
proxy: {'/graphql': `http://localhost:${GRAPHQL_PORT}`},
publicPath: config.output.publicPath,
stats: {
colors: true,
hash: false,
timings: true,
chunks: false,
chunkModules: false,
modules: false
}
});
app.use(webpackHotMiddleware(compiler));
app.listen(APP_PORT, () => {
console.log(`App is now running on http://localhost:${APP_PORT}`);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment