-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
37 lines (27 loc) · 1.09 KB
/
Copy pathindex.js
File metadata and controls
37 lines (27 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
const server = require("./server");
const defaultOpts = { dir:"public", port:3000, host:"localhost", index:"index.html", proxy:{} };
module.exports = (opts) => {
opts = { ...defaultOpts, ...opts }
var clientCode = require("fs").readFileSync(require.resolve("./client/client.js", "utf-8")).toString().replace("%port%", opts.port).replace("%host%", opts.host);
server.start(opts);
return {
name: "devsuite",
banner() {
return clientCode;
},
writeBundle(_, bundle) {
for(file in bundle) {
if(bundle[file].type === "chunk") {
server.update(file, bundle[file].code);
//console.log(bundle[file].map);
//for(x in bundle[file].map) {console.log(x)};
if(bundle[file].map) {
server.update(file + ".map", bundle[file].map.file);
}
} else if (bundle[file].type === "asset"){
server.update(file, bundle[file].source);
}
}
}
}
}