Skip to content

Commit 572133a

Browse files
committedApr 22, 2022
docs(examples): update example with webpack
1 parent 6e1bb62 commit 572133a

10 files changed

+30
-109
lines changed
 

‎examples/webpack-build/README.md

+1-10
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,5 @@ A sample Webpack build for the browser.
77

88
```
99
$ npm i
10-
$ npm run build-all
10+
$ npm run build
1111
```
12-
13-
There are two WebPack configuration:
14-
15-
- the minimal configuration, just bundling the application and its dependencies. The `app.js` file in the `dist` folder is the result of that build.
16-
17-
- a slimmer one, where:
18-
- the JSON polyfill needed for IE6/IE7 support has been removed.
19-
- the `debug` calls and import have been removed (the [debug](https://github.com/visionmedia/debug) library is included in the build by default).
20-
- the source has been uglified (dropping IE8 support), and an associated SourceMap has been generated.

‎examples/webpack-build/index.html

+2-3
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
</head>
77
<body>
88

9-
<!-- <script src="dist/app.js"></script> -->
10-
<script src="dist/app.slim.js"></script>
9+
<script src="dist/bundle.js"></script>
1110

1211
</body>
13-
</html>
12+
</html>

‎examples/webpack-build/index.js

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { io } from "socket.io-client";
2+
3+
const socket = io("http://localhost:3000");
4+
5+
socket.on("connect", () => {
6+
console.log(`connect ${socket.id}`);
7+
});
8+
9+
socket.on("connect_error", (err) => {
10+
console.log(`connect_error due to ${err.message}`);
11+
});
12+
13+
socket.on("disconnect", (reason) => {
14+
console.log(`disconnect due to ${reason}`);
15+
});

‎examples/webpack-build/lib/index.js

-12
This file was deleted.

‎examples/webpack-build/package.json

+5-10
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,15 @@
22
"name": "webpack-build",
33
"version": "1.0.0",
44
"description": "A sample Webpack build",
5+
"type": "module",
56
"scripts": {
6-
"build": "webpack --config ./support/webpack.config.js",
7-
"build-slim": "webpack --config ./support/webpack.config.slim.js",
8-
"build-json-parser": "webpack --config ./support/webpack.config.json-parser.js",
9-
"build-all": "npm run build && npm run build-slim && npm run build-json-parser"
7+
"build": "webpack"
108
},
119
"author": "Damien Arrachequesne",
1210
"license": "MIT",
1311
"dependencies": {
14-
"socket.io-client": "^2.0.2",
15-
"socket.io-json-parser": "^2.1.0"
16-
},
17-
"devDependencies": {
18-
"strip-loader": "^0.1.2",
19-
"webpack": "^2.6.1"
12+
"socket.io-client": "^4.4.1",
13+
"webpack": "^5.72.0",
14+
"webpack-cli": "^4.9.2"
2015
}
2116
}

‎examples/webpack-build/support/noop.js

-2
This file was deleted.

‎examples/webpack-build/support/webpack.config.js

-8
This file was deleted.

‎examples/webpack-build/support/webpack.config.json-parser.js

-33
This file was deleted.

‎examples/webpack-build/support/webpack.config.slim.js

-31
This file was deleted.
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export default {
2+
entry: "./index.js",
3+
mode: "production",
4+
output: {
5+
filename: "bundle.js",
6+
},
7+
};

0 commit comments

Comments
 (0)
Please sign in to comment.