Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: convert dev server to webpack plugin #3850

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
9 changes: 9 additions & 0 deletions lib/Server.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,16 @@ class Server {
// Keep track of websocket proxies for external websocket upgrade.
this.webSocketProxies = [];
this.sockets = [];

// TODO: remove this after plugin support is published
if (compiler) {
rishabh3112 marked this conversation as resolved.
Show resolved Hide resolved
this.compiler = compiler;
}
}

apply(compiler) {
this.compiler = compiler;
this.start();
}

static get DEFAULT_STATS() {
Expand Down
11 changes: 11 additions & 0 deletions test/server/Server.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,17 @@ describe("Server", () => {
}
}

it("should accept plugin API", (done) => {
const compiler = webpack(config);
const server = new Server(baseDevConfig);
server.apply(compiler);

compiler.hooks.done.tap("webpack-dev-server", () => {
expect(true).toBe(true);
server.stopCallback(done);
});
});
rishabh3112 marked this conversation as resolved.
Show resolved Hide resolved

it("add hot option", (done) => {
const compiler = webpack(config);
const server = new Server({ ...baseDevConfig, hot: true }, compiler);
Expand Down