diff --git a/examples/cli/web-server-socket/README.md b/examples/cli/web-server-socket/README.md new file mode 100644 index 0000000000..5ed171b928 --- /dev/null +++ b/examples/cli/web-server-socket/README.md @@ -0,0 +1,24 @@ +# CLI: web-socket-server + +To create a custom server implementation. + +## sockjs + +This mode uses [SockJS-node](https://github.com/sockjs/sockjs-node) as a server. + +```console +npx webpack serve --web-socket-server sockjs --open-target +``` + +## ws + +This mode uses [ws](https://github.com/websockets/ws) as a server. + +```console +npx webpack serve --web-socket-server ws --open-target +``` + +### What Should Happen + +1. The script should open `http://localhost:8080/` in your default browser. +2. You should see the text on the page itself change to read `Success!`. diff --git a/examples/cli/web-server-socket/app.js b/examples/cli/web-server-socket/app.js new file mode 100644 index 0000000000..ae384858b9 --- /dev/null +++ b/examples/cli/web-server-socket/app.js @@ -0,0 +1,6 @@ +'use strict'; + +const target = document.querySelector('#target'); + +target.classList.add('pass'); +target.innerHTML = 'Success!'; diff --git a/examples/cli/web-server-socket/webpack.config.js b/examples/cli/web-server-socket/webpack.config.js new file mode 100644 index 0000000000..e0e5363925 --- /dev/null +++ b/examples/cli/web-server-socket/webpack.config.js @@ -0,0 +1,10 @@ +'use strict'; + +// our setup function adds behind-the-scenes bits to the config that all of our +// examples need +const { setup } = require('../../util'); + +module.exports = setup({ + context: __dirname, + entry: './app.js', +});