Skip to content

Commit

Permalink
docs(examples): update example with webpack
Browse files Browse the repository at this point in the history
  • Loading branch information
darrachequesne committed Apr 22, 2022
1 parent 6e1bb62 commit 572133a
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 109 deletions.
11 changes: 1 addition & 10 deletions examples/webpack-build/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,5 @@ A sample Webpack build for the browser.

```
$ npm i
$ npm run build-all
$ npm run build
```

There are two WebPack configuration:

- the minimal configuration, just bundling the application and its dependencies. The `app.js` file in the `dist` folder is the result of that build.

- a slimmer one, where:
- the JSON polyfill needed for IE6/IE7 support has been removed.
- the `debug` calls and import have been removed (the [debug](https://github.com/visionmedia/debug) library is included in the build by default).
- the source has been uglified (dropping IE8 support), and an associated SourceMap has been generated.
5 changes: 2 additions & 3 deletions examples/webpack-build/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
</head>
<body>

<!-- <script src="dist/app.js"></script> -->
<script src="dist/app.slim.js"></script>
<script src="dist/bundle.js"></script>

</body>
</html>
</html>
15 changes: 15 additions & 0 deletions examples/webpack-build/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { io } from "socket.io-client";

const socket = io("http://localhost:3000");

socket.on("connect", () => {
console.log(`connect ${socket.id}`);
});

socket.on("connect_error", (err) => {
console.log(`connect_error due to ${err.message}`);
});

socket.on("disconnect", (reason) => {
console.log(`disconnect due to ${reason}`);
});
12 changes: 0 additions & 12 deletions examples/webpack-build/lib/index.js

This file was deleted.

15 changes: 5 additions & 10 deletions examples/webpack-build/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,15 @@
"name": "webpack-build",
"version": "1.0.0",
"description": "A sample Webpack build",
"type": "module",
"scripts": {
"build": "webpack --config ./support/webpack.config.js",
"build-slim": "webpack --config ./support/webpack.config.slim.js",
"build-json-parser": "webpack --config ./support/webpack.config.json-parser.js",
"build-all": "npm run build && npm run build-slim && npm run build-json-parser"
"build": "webpack"
},
"author": "Damien Arrachequesne",
"license": "MIT",
"dependencies": {
"socket.io-client": "^2.0.2",
"socket.io-json-parser": "^2.1.0"
},
"devDependencies": {
"strip-loader": "^0.1.2",
"webpack": "^2.6.1"
"socket.io-client": "^4.4.1",
"webpack": "^5.72.0",
"webpack-cli": "^4.9.2"
}
}
2 changes: 0 additions & 2 deletions examples/webpack-build/support/noop.js

This file was deleted.

8 changes: 0 additions & 8 deletions examples/webpack-build/support/webpack.config.js

This file was deleted.

33 changes: 0 additions & 33 deletions examples/webpack-build/support/webpack.config.json-parser.js

This file was deleted.

31 changes: 0 additions & 31 deletions examples/webpack-build/support/webpack.config.slim.js

This file was deleted.

7 changes: 7 additions & 0 deletions examples/webpack-build/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default {
entry: "./index.js",
mode: "production",
output: {
filename: "bundle.js",
},
};

0 comments on commit 572133a

Please sign in to comment.