Skip to content

Commit 5765394

Browse files
authored
chore: fix webpack dev server (#1169)
1 parent 76b153a commit 5765394

File tree

6 files changed

+63
-247
lines changed

6 files changed

+63
-247
lines changed

examples/graphiql-webpack/package.json

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
"start": "webpack serve"
1010
},
1111
"dependencies": {
12-
"express": "^4.17.1",
13-
"express-graphql": "^0.9.0",
1412
"graphiql": "file:../../packages/graphiql",
1513
"graphql": "14.5.8",
1614
"react": "16.12.0"
@@ -19,14 +17,14 @@
1917
"@babel/plugin-proposal-class-properties": "7.7.4",
2018
"@babel/plugin-syntax-dynamic-import": "7.7.4",
2119
"@babel/preset-env": "7.7.7",
22-
"@babel/preset-react": "7.7.0",
20+
"@babel/preset-react": "7.7.4",
2321
"babel-loader": "^8.0.6",
2422
"css-loader": "3.4.0",
2523
"html-webpack-plugin": "^3.2.0",
26-
"react-dom": "^16.11.0",
27-
"style-loader": "^1.0.0",
28-
"webpack": "^4.41.0",
29-
"webpack-cli": "^3.3.9",
30-
"webpack-dev-server": "^3.9.0"
24+
"react-dom": "^16.12.0",
25+
"style-loader": "^1.1.2",
26+
"webpack": "4.41.4",
27+
"webpack-cli": "^3.3.10",
28+
"webpack-dev-server": "^3.10.1"
3129
}
3230
}

packages/graphiql/package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"build-flow": "node ../../resources/buildFlow.js",
3636
"build-demo": "build-storybook -o ./storybook",
3737
"check": "flow check",
38-
"dev": "cross-env NODE_ENV=development node test/dev-server.js",
38+
"dev": "cross-env NODE_ENV=development webpack-dev-server --config resources/webpack.config.js",
3939
"cypress-open": "yarn e2e-server 'cypress open'",
4040
"e2e": "yarn e2e-server 'cypress run'",
4141
"e2e-server": "start-server-and-test 'cross-env PORT=8080 node test/e2e-server' 'http-get://localhost:8080/graphql?query={test { id }}'",
@@ -66,7 +66,7 @@
6666
"cssnano": "^4.1.10",
6767
"enzyme": "^3.10.0",
6868
"enzyme-adapter-react-16": "^1.15.1",
69-
"express": "5.0.0-alpha.5",
69+
"express": "4.17.1",
7070
"express-graphql": "0.9.0",
7171
"graphql": "14.5.8",
7272
"html-webpack-plugin": "^3.2.0",
@@ -86,7 +86,9 @@
8686
"serve": "^11.2.0",
8787
"start-server-and-test": "^1.10.6",
8888
"style-loader": "^1.0.0",
89+
"webpack": "4.41.4",
8990
"webpack-bundle-analyzer": "^3.6.0",
90-
"webpack-cli": "^3.3.10"
91+
"webpack-cli": "^3.3.10",
92+
"webpack-dev-server": "^3.10.1"
9193
}
9294
}

packages/graphiql/resources/webpack.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ const resultConfig = {
3434
// bypass simple localhost CORS restrictions by setting
3535
// these to 127.0.0.1 in /etc/hosts
3636
allowedHosts: ['local.example.com', 'graphiql.com'],
37+
before: require('../test/beforeDevServer'),
3738
},
3839
node: {
3940
fs: 'empty',
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/**
2+
* Copyright (c) 2019 GraphQL Contributors.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
const express = require('express');
9+
const path = require('path');
10+
const graphqlHTTP = require('express-graphql');
11+
const schema = require('./schema');
12+
13+
module.exports = function beforeDevServer(app, _server, _compiler) {
14+
// GraphQL Server
15+
app.post('/graphql', graphqlHTTP({ schema }));
16+
17+
app.get(
18+
'/graphql',
19+
graphqlHTTP({
20+
schema,
21+
}),
22+
);
23+
24+
app.use('/images', express.static(path.join(__dirname, 'images')));
25+
26+
app.use(
27+
'/renderExample.js',
28+
express.static(path.join(__dirname, '../resources/renderExample.js')),
29+
);
30+
};

packages/graphiql/test/dev-server.js

Lines changed: 0 additions & 48 deletions
This file was deleted.

0 commit comments

Comments
 (0)