MCPcopy
hub / github.com/FormidableLabs/webpack-dashboard / apply

Method apply

plugin/index.js:91–268  ·  view source on GitHub ↗
(compiler)

Source from the content-addressed store, hash-verified

89 }
90
91 apply(compiler) {
92 // Reached compile "done" state.
93 let reachedDone = false;
94 // Compile has finished in "done", "error", "failed" states.
95 let finished = false;
96 let timer;
97
98 if (!this._handler) {
99 this._handler = noop;
100 const port = this.port;
101 const host = this.host;
102 this.socket = io(`http://${host}:${port}`);
103 this.socket.on("connect", () => {
104 // Manually track messages we send to the dashboard and decrement later.
105 const socketMsg = this.socket.emit.bind(this.socket, "message");
106 const ack = () => {
107 this.openMessages--;
108 };
109 this._handler = (...args) => {
110 this.openMessages++;
111 socketMsg(...args, ack);
112 };
113 });
114 this.socket.once("options", args => {
115 this.minimal = args.minimal;
116 this.includeAssets = this.includeAssets.concat(args.includeAssets || []);
117 });
118 this.socket.on("error", err => {
119 // eslint-disable-next-line no-console
120 console.log(err);
121 });
122 this.socket.on("disconnect", () => {
123 if (!reachedDone) {
124 // eslint-disable-next-line no-console
125 console.log("Socket.io disconnected before completing build lifecycle.");
126 }
127 });
128 }
129
130 new webpack.ProgressPlugin((percent, msg) => {
131 // Skip reporting once finished.
132 if (finished) {
133 return;
134 }
135
136 this.handler([
137 {
138 type: "status",
139 value: "Compiling"
140 },
141 {
142 type: "progress",
143 value: percent
144 },
145 {
146 type: "operations",
147 value: msg + getTimeMessage(timer)
148 }

Callers 1

index.spec.jsFile · 0.80

Calls 3

handlerMethod · 0.95
cleanupMethod · 0.95
getTimeMessageFunction · 0.85

Tested by

no test coverage detected