Skip to content
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) {
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);
});
});

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