1 | import path, { resolve } from 'node:path';
|
---|
2 | import { fileURLToPath } from 'node:url';
|
---|
3 | import { readFileSync } from 'node:fs';
|
---|
4 |
|
---|
5 | const { version } = JSON.parse(
|
---|
6 | readFileSync(new URL("../../package.json", import.meta.url)).toString()
|
---|
7 | );
|
---|
8 | const VERSION = version;
|
---|
9 | const DEFAULT_MAIN_FIELDS = [
|
---|
10 | "browser",
|
---|
11 | "module",
|
---|
12 | "jsnext:main",
|
---|
13 | // moment still uses this...
|
---|
14 | "jsnext"
|
---|
15 | ];
|
---|
16 | const ESBUILD_MODULES_TARGET = [
|
---|
17 | "es2020",
|
---|
18 | // support import.meta.url
|
---|
19 | "edge88",
|
---|
20 | "firefox78",
|
---|
21 | "chrome87",
|
---|
22 | "safari14"
|
---|
23 | ];
|
---|
24 | const DEFAULT_EXTENSIONS = [
|
---|
25 | ".mjs",
|
---|
26 | ".js",
|
---|
27 | ".mts",
|
---|
28 | ".ts",
|
---|
29 | ".jsx",
|
---|
30 | ".tsx",
|
---|
31 | ".json"
|
---|
32 | ];
|
---|
33 | const DEFAULT_CONFIG_FILES = [
|
---|
34 | "vite.config.js",
|
---|
35 | "vite.config.mjs",
|
---|
36 | "vite.config.ts",
|
---|
37 | "vite.config.cjs",
|
---|
38 | "vite.config.mts",
|
---|
39 | "vite.config.cts"
|
---|
40 | ];
|
---|
41 | const JS_TYPES_RE = /\.(?:j|t)sx?$|\.mjs$/;
|
---|
42 | const CSS_LANGS_RE = /\.(css|less|sass|scss|styl|stylus|pcss|postcss|sss)(?:$|\?)/;
|
---|
43 | const OPTIMIZABLE_ENTRY_RE = /\.[cm]?[jt]s$/;
|
---|
44 | const SPECIAL_QUERY_RE = /[?&](?:worker|sharedworker|raw|url)\b/;
|
---|
45 | const FS_PREFIX = `/@fs/`;
|
---|
46 | const CLIENT_PUBLIC_PATH = `/@vite/client`;
|
---|
47 | const ENV_PUBLIC_PATH = `/@vite/env`;
|
---|
48 | const VITE_PACKAGE_DIR = resolve(
|
---|
49 | // import.meta.url is `dist/node/constants.js` after bundle
|
---|
50 | fileURLToPath(import.meta.url),
|
---|
51 | "../../.."
|
---|
52 | );
|
---|
53 | const CLIENT_ENTRY = resolve(VITE_PACKAGE_DIR, "dist/client/client.mjs");
|
---|
54 | const ENV_ENTRY = resolve(VITE_PACKAGE_DIR, "dist/client/env.mjs");
|
---|
55 | const CLIENT_DIR = path.dirname(CLIENT_ENTRY);
|
---|
56 | const KNOWN_ASSET_TYPES = [
|
---|
57 | // images
|
---|
58 | "apng",
|
---|
59 | "bmp",
|
---|
60 | "png",
|
---|
61 | "jpe?g",
|
---|
62 | "jfif",
|
---|
63 | "pjpeg",
|
---|
64 | "pjp",
|
---|
65 | "gif",
|
---|
66 | "svg",
|
---|
67 | "ico",
|
---|
68 | "webp",
|
---|
69 | "avif",
|
---|
70 | // media
|
---|
71 | "mp4",
|
---|
72 | "webm",
|
---|
73 | "ogg",
|
---|
74 | "mp3",
|
---|
75 | "wav",
|
---|
76 | "flac",
|
---|
77 | "aac",
|
---|
78 | "opus",
|
---|
79 | "mov",
|
---|
80 | "m4a",
|
---|
81 | "vtt",
|
---|
82 | // fonts
|
---|
83 | "woff2?",
|
---|
84 | "eot",
|
---|
85 | "ttf",
|
---|
86 | "otf",
|
---|
87 | // other
|
---|
88 | "webmanifest",
|
---|
89 | "pdf",
|
---|
90 | "txt"
|
---|
91 | ];
|
---|
92 | const DEFAULT_ASSETS_RE = new RegExp(
|
---|
93 | `\\.(` + KNOWN_ASSET_TYPES.join("|") + `)(\\?.*)?$`
|
---|
94 | );
|
---|
95 | const DEP_VERSION_RE = /[?&](v=[\w.-]+)\b/;
|
---|
96 | const loopbackHosts = /* @__PURE__ */ new Set([
|
---|
97 | "localhost",
|
---|
98 | "127.0.0.1",
|
---|
99 | "::1",
|
---|
100 | "0000:0000:0000:0000:0000:0000:0000:0001"
|
---|
101 | ]);
|
---|
102 | const wildcardHosts = /* @__PURE__ */ new Set([
|
---|
103 | "0.0.0.0",
|
---|
104 | "::",
|
---|
105 | "0000:0000:0000:0000:0000:0000:0000:0000"
|
---|
106 | ]);
|
---|
107 | const DEFAULT_DEV_PORT = 5173;
|
---|
108 | const DEFAULT_PREVIEW_PORT = 4173;
|
---|
109 | const DEFAULT_ASSETS_INLINE_LIMIT = 4096;
|
---|
110 | const METADATA_FILENAME = "_metadata.json";
|
---|
111 |
|
---|
112 | export { CLIENT_DIR, CLIENT_ENTRY, CLIENT_PUBLIC_PATH, CSS_LANGS_RE, DEFAULT_ASSETS_INLINE_LIMIT, DEFAULT_ASSETS_RE, DEFAULT_CONFIG_FILES, DEFAULT_DEV_PORT, DEFAULT_EXTENSIONS, DEFAULT_MAIN_FIELDS, DEFAULT_PREVIEW_PORT, DEP_VERSION_RE, ENV_ENTRY, ENV_PUBLIC_PATH, ESBUILD_MODULES_TARGET, FS_PREFIX, JS_TYPES_RE, KNOWN_ASSET_TYPES, METADATA_FILENAME, OPTIMIZABLE_ENTRY_RE, SPECIAL_QUERY_RE, VERSION, VITE_PACKAGE_DIR, loopbackHosts, wildcardHosts };
|
---|