gulp-websocket-server
The main purpose of this plugn is to open a websocket service in gulp, and then send the message to the client who has already created the link when the file changes.
Install
npm install --save-dev gulp-websocket-server
Usage
How use in gulp
const gulp = ;const gulpWss = ;const serverConfig = port: 4000 path: '/ws';//build a websocket server in gulplet wss = ; //gulp;gulp;
websocket server's creation configuration refer to ws.
Webscoket server's instance has livereload
and send
methods,they all can send message to client.livereload
only can be used in gulp's pipe.send
can be use directly.They both has only one parameter that is message needed to be sent.The default value for this parameter file change
How to use in client
You can build link like above and wait for message and then do what you want do.
const ws = 'ws://localhost:yourport/yourpath';ws;ws;