Skip to content

Commit 74a3739

Browse files
committed
Build before serving app
1 parent fcf305b commit 74a3739

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

benchmarks/compat/tests/utils.js

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,36 @@ const PORT = 3000;
1818

1919
export class App {
2020
constructor() {
21-
const compiler = webpack({
21+
this.compiler = webpack({
2222
mode: "development",
23-
entry: path.join(__dirname, "../index.js")
23+
entry: path.join(__dirname, "../index.js"),
24+
output: {
25+
path: path.join(__dirname, "../dist"),
26+
filename: "index.js",
27+
}
2428
});
2529

2630
this.server = new DevServer({
2731
static: {
2832
directory: path.join(__dirname, "../"),
2933
},
3034
port: 3000,
31-
}, compiler);
35+
}, this.compiler);
36+
}
37+
38+
async build() {
39+
await new Promise((resolve, reject) => {
40+
this.compiler.run(err => {
41+
if (err) reject(err);
42+
resolve();
43+
44+
this.compiler.close(closeErr => reject(closeErr));
45+
});
46+
});
3247
}
3348

3449
async start() {
50+
await this.build();
3551
console.log("Starting server...");
3652
await this.server.start();
3753
}

0 commit comments

Comments
 (0)