-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.js
65 lines (53 loc) · 1.54 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import { createReloadable } from '@artsy/express-reloadable';
import CopyWebpackPlugin from 'copy-webpack-plugin';
import FriendlyErrorsWebpackPlugin from 'friendly-errors-webpack-plugin';
import express from 'express';
import graphQLHTTP from 'express-graphql';
import path from 'path';
import webpack from 'webpack';
import webpackMiddleware from 'webpack-dev-middleware';
import schema from './src/data/schema';
const PORT = 8080;
const app = express();
app.use('/graphql', graphQLHTTP({ schema }));
const mountAndReload = createReloadable(app, require);
mountAndReload(path.resolve(__dirname, './src'));
const webpackConfig = {
mode: 'development',
entry: ['babel-polyfill', './src/client'],
output: {
path: '/',
filename: 'bundle.js',
},
module: {
rules: [
// See: https://github.com/aws/aws-amplify/issues/686#issuecomment-387710340
{
test: /\.mjs$/,
include: /node_modules/,
type: 'javascript/auto',
},
{ test: /\.js$/, exclude: /node_modules/, use: 'babel-loader' },
],
},
plugins: [
new CopyWebpackPlugin([
'src/assets',
'node_modules/todomvc-common/base.css',
'node_modules/todomvc-app-css/index.css',
]),
new FriendlyErrorsWebpackPlugin({
compilationSuccessInfo: {
messages: [`[App] Listening on http://localhost:${PORT} \n`],
},
}),
],
};
app.use(
webpackMiddleware(webpack(webpackConfig), {
stats: { colors: true },
}),
);
app.listen(PORT, () => {
console.log(`Booting...`); // eslint-disable-line no-console
});