-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.mjs
51 lines (46 loc) · 1.28 KB
/
vite.config.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import { defineConfig } from "vite";
import { viteStaticCopy } from "vite-plugin-static-copy";
import mkcert from 'vite-plugin-mkcert'
import dns from 'dns';
let DEV_DOMAIN = 'wcmw.dev';
// Prevent lookup_orig from being overwritten when it is already defined
if (dns.lookup_orig === undefined) {
// Save the original lookup function
dns.lookup_orig = dns.lookup;
}
// https://nodejs.org/api/dns.html#dnslookuphostname-options-callback
const customLookup = (hostname, options, callback) => {
if (hostname === DEV_DOMAIN) {
const address = '0.0.0.0';
if (typeof options === 'function') {
// If options is omitted and callback is provided directly
callback = options;
}
callback(null, address, 4);
} else {
// Forward other DNS queries to the original lookup function
dns.lookup_orig(hostname, options, callback);
}
}
// Override the built-in lookup function
dns.lookup = customLookup;
export default defineConfig({
base: "./",
server: {
host: DEV_DOMAIN,
https: true,
port: 443,
},
build: {
outDir: "_site",
},
plugins: [
mkcert(),
viteStaticCopy({
targets: [
{ src: "robots.txt", dest: "." },
{ src: "404.html", dest: "." },
],
}),
],
});