-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup-dev.mjs
35 lines (32 loc) · 1.01 KB
/
rollup-dev.mjs
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
import serve from "rollup-plugin-serve";
const host = "localhost";
const content_dir = "dist/";
export function makeDevConfig(rollupConfig, port) {
rollupConfig.plugins = [
// options: https://github.com/thgh/rollup-plugin-serve/tree/master?tab=readme-ov-file#options
serve({
contentBase: content_dir,
historyApiFallback: true,
host: host,
port: port,
onListening: function (server) {
const address = server.address();
const host =
address.address === "::" || address.address === "::1"
? "localhost"
: address.address;
const protocol = this.https ? "https" : "http";
if (port !== 10005) {
console.log(
`<script src="${protocol}://${host}:${address.port}/index.browser.js"></script>`,
);
} else {
console.log(
`<link rel="stylesheet" href="${protocol}://${host}:${address.port}/index.css">`,
);
}
},
}),
];
return rollupConfig;
}