Skip to content

Commit 7541a84

Browse files
committed
demo: Update to the latest webpack
1 parent 029cb0f commit 7541a84

9 files changed

+1670
-2318
lines changed

demo/custom.d.ts

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
declare module '*.css' {
2+
var content: any;
3+
export = content;
4+
}

demo/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ const defaultTabConfig = {
5353
variables: ''
5454
};
5555

56-
export class Demo extends React.Component<null, any> {
56+
export class Demo extends React.Component<{}, any> {
5757
constructor(props) {
5858
super(props);
5959
let config = new AppConfig("graphiql", workspaceOptions);

demo/tsconfig.json

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"compilerOptions": {
3+
"experimentalDecorators": true,
4+
"emitDecoratorMetadata": true,
5+
"sourceMap": true,
6+
"target": "es5",
7+
"noImplicitAny": false,
8+
"noUnusedLocals": true,
9+
"noUnusedParameters": true,
10+
"outDir": "dist",
11+
"moduleResolution": "node",
12+
"lib": ["es2017", "dom"],
13+
"jsx": "react",
14+
"esModuleInterop": true
15+
},
16+
"include": ["./custom.d.ts", "**/*.tsx", "**/*.ts"]
17+
}

demo/webpack.demo.js

+20-27
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,38 @@
1-
const webpack = require('webpack');
2-
const ExtractTextPlugin = require('extract-text-webpack-plugin');
31
const path = require('path');
4-
5-
function root(args) {
6-
args = Array.prototype.slice.call(arguments, 0);
7-
return path.join.apply(path, [__dirname].concat(args));
8-
}
2+
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
93

104
module.exports = {
115
devtool: 'source-map',
12-
performance: {
13-
hints: false
14-
},
156
devServer: {
16-
contentBase: root('.'),
7+
contentBase: __dirname,
178
watchContentBase: true,
189
port: 9005,
19-
stats: 'errors-only'
20-
},
21-
resolve: {
22-
extensions: ['.ts', '.tsx', '.js', '.json']
23-
},
24-
entry: ['./demo/index.tsx'],
25-
output: {
26-
path: root('.'),
27-
filename: 'bundle.js',
28-
sourceMapFilename: '[file].map'
2910
},
11+
entry: './demo/index.tsx',
12+
plugins: [new MiniCssExtractPlugin({ filename: 'bundle.css' })],
3013
module: {
3114
rules: [
3215
{
3316
test: /\.tsx?$/,
34-
use: ['awesome-typescript-loader'],
17+
use: 'ts-loader',
18+
exclude: /node_modules/,
3519
},
3620
{
3721
test: /\.css$/,
38-
use: ExtractTextPlugin.extract({ use: 'css-loader' }),
22+
use: [
23+
'style-loader',
24+
MiniCssExtractPlugin.loader,
25+
{ loader: 'css-loader', options: { importLoaders: 1 } },
26+
],
3927
},
4028
],
4129
},
42-
plugins: [
43-
new ExtractTextPlugin({filename: 'bundle.css', allChunks: true}),
44-
]
45-
}
30+
resolve: {
31+
extensions: ['.tsx', '.ts', '.mjs', '.js'],
32+
},
33+
output: {
34+
path: __dirname,
35+
filename: 'bundle.js',
36+
sourceMapFilename: '[file].map'
37+
},
38+
};

manual-types.d.ts

Whitespace-only changes.

package.json

+8-8
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,20 @@
4040
"@types/lodash-es": "4.17.3",
4141
"@types/react": "15.6.28",
4242
"@types/react-dom": "15.5.12",
43-
"@types/webpack": "3.8.19",
44-
"awesome-typescript-loader": "3.5.0",
45-
"css-loader": "0.28.7",
43+
"css-loader": "4.2.1",
4644
"deploy-to-gh-pages": "1.3.7",
47-
"extract-text-webpack-plugin": "3.0.2",
4845
"graphiql": "0.11.10",
4946
"graphiql-workspace": "github:apis-guru/graphiql-workspace#tab-fork-dist",
47+
"mini-css-extract-plugin": "^0.10.0",
5048
"react": "15.5.4",
5149
"react-dom": "15.5.4",
5250
"react-modal": "3.11.2",
5351
"rimraf": "2.7.1",
54-
"style-loader": "0.19.1",
55-
"typescript": "2.9.2",
56-
"webpack": "3.12.0",
57-
"webpack-dev-server": "2.11.5"
52+
"style-loader": "1.2.1",
53+
"ts-loader": "^8.0.3",
54+
"typescript": "3.6.3",
55+
"webpack": "4.44.1",
56+
"webpack-cli": "^3.3.12",
57+
"webpack-dev-server": "3.11.0"
5858
}
5959
}

tsconfig.json

+4-16
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"experimentalDecorators": true,
44
"emitDecoratorMetadata": true,
55
"module": "es2015",
6-
"moduleResolution": "node",
76
"target": "es5",
87
"noImplicitAny": false,
98
"noUnusedLocals": true,
@@ -12,25 +11,14 @@
1211
"declaration": true,
1312
"outDir": "lib",
1413
"pretty": true,
15-
"types": [
16-
"webpack"
17-
],
18-
"lib": ["es2017", "DOM", "esnext.asynciterable"],
19-
"jsx": "react"
14+
"moduleResolution": "node",
15+
"lib": ["es2017"]
2016
},
2117
"compileOnSave": false,
2218
"exclude": [
19+
"demo",
2320
"node_modules",
2421
".tmp",
2522
"lib"
26-
],
27-
"include": [
28-
"./src/**/*.ts",
29-
"./src/**/*.tsx",
30-
"./manual-types.d.ts"
31-
],
32-
"awesomeTypescriptLoaderOptions": {
33-
"resolveGlobs": true,
34-
"useWebpackText": true
35-
}
23+
]
3624
}

webpack.config.js

+6-16
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,13 @@
1-
const webpack = require('webpack');
21
const path = require('path');
32

4-
function root(args) {
5-
args = Array.prototype.slice.call(arguments, 0);
6-
return path.join.apply(path, [__dirname].concat(args));
7-
}
8-
93
module.exports = {
104
devtool: 'source-map',
11-
performance: {
12-
hints: false
13-
},
5+
entry: ['./src/index.ts'],
146
resolve: {
15-
extensions: ['.ts', '.tsx', '.js', '.json']
7+
extensions: ['.tsx', '.ts', '.mjs', '.js'],
168
},
17-
entry: ['./src/index.ts'],
189
output: {
19-
path: root('lib'),
10+
path: path.join(__dirname, 'lib'),
2011
filename: 'graphql-lodash.bundle.js',
2112
sourceMapFilename: '[file].map',
2213
library: 'GQLLodash',
@@ -26,10 +17,9 @@ module.exports = {
2617
module: {
2718
rules: [
2819
{
29-
test: /\.tsx?$/,
30-
use: [
31-
'awesome-typescript-loader'
32-
]
20+
test: /\.ts$/,
21+
use: 'ts-loader',
22+
exclude: /node_modules/,
3323
}
3424
]
3525
}

0 commit comments

Comments
 (0)