vike 0.4.259-commit-286bd57 → 0.4.259-commit-9fc8a01
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -8,6 +8,7 @@ import { loadConfigFromFile, mergeConfig, resolveConfig } from 'vite';
|
|
|
8
8
|
import { getVikeConfigInternal, getVikeConfigFromCliOrEnv, setVikeConfigContext, isVikeConfigContextSet, EARLY_SETTINGS, } from '../vite/shared/resolveVikeConfigInternal.js';
|
|
9
9
|
import path from 'node:path';
|
|
10
10
|
import { assert, assertUsage, assertWarning } from '../../utils/assert.js';
|
|
11
|
+
import { createDebug } from '../../utils/debug.js';
|
|
11
12
|
import { getGlobalObject } from '../../utils/getGlobalObject.js';
|
|
12
13
|
import { pick } from '../../utils/pick.js';
|
|
13
14
|
import { toPosixPath } from '../../utils/path.js';
|
|
@@ -17,6 +18,7 @@ import { getVikeApiOperation, isVikeCliOrApi } from '../../shared-server-node/ap
|
|
|
17
18
|
import { getViteCliCommand, getViteCliArgs } from '../vite/shared/isViteCli.js';
|
|
18
19
|
import './assertEnvApiDevAndProd.js';
|
|
19
20
|
const globalObject = getGlobalObject('resolveViteConfigUser.ts', {});
|
|
21
|
+
const debug = createDebug('vike:vite-config-user');
|
|
20
22
|
async function resolveViteConfigUser() {
|
|
21
23
|
const { viteContext } = getVikeApiContext();
|
|
22
24
|
assert(viteContext);
|
|
@@ -73,22 +75,32 @@ async function resolve(viteContext) {
|
|
|
73
75
|
const { viteConfigFromVikeApi, vikeConfigFromApi } = getVikeApiContext();
|
|
74
76
|
addConfig(viteConfigFromVikeApi); // `viteConfig`
|
|
75
77
|
addConfig(pick(vikeConfigFromApi ?? {}, EARLY_SETTINGS)); // `+mode` & `+root`
|
|
78
|
+
if (debug.isActivated)
|
|
79
|
+
debug('viteConfigFromVikeApi', viteConfigFromVikeApi);
|
|
80
|
+
if (debug.isActivated)
|
|
81
|
+
debug('vikeConfigFromApi', vikeConfigFromApi);
|
|
76
82
|
}
|
|
77
83
|
// Vite CLI args (when invoked via Vite's CLI rather than Vike's API).
|
|
78
84
|
// - Without this, Vike loads vite.config.js blind to `vite [root]` / `-c <file>` and ends up with the wrong root when those Vite CLI args are used.
|
|
79
85
|
{
|
|
80
86
|
const viteConfigFromViteCli = getViteCliArgs();
|
|
81
87
|
addConfig(viteConfigFromViteCli);
|
|
88
|
+
if (debug.isActivated)
|
|
89
|
+
debug('viteConfigFromViteCli', viteConfigFromViteCli);
|
|
82
90
|
}
|
|
83
91
|
// Vike's CLI and VIKE_CONFIG — `+mode` & `+root`
|
|
84
92
|
{
|
|
85
93
|
const viteConfigFromVikeCliOrEnv = pick(getVikeConfigFromCliOrEnv().vikeConfigFromCliOrEnv, EARLY_SETTINGS);
|
|
86
94
|
addConfig(viteConfigFromVikeCliOrEnv);
|
|
95
|
+
if (debug.isActivated)
|
|
96
|
+
debug('viteConfigFromVikeCliOrEnv', viteConfigFromVikeCliOrEnv);
|
|
87
97
|
}
|
|
88
98
|
// VITE_CONFIG
|
|
89
99
|
{
|
|
90
100
|
const viteConfigFromViteEnv = getEnvVarObject('VITE_CONFIG');
|
|
91
101
|
addConfig(viteConfigFromViteEnv);
|
|
102
|
+
if (debug.isActivated)
|
|
103
|
+
debug('viteConfigFromViteEnv', viteConfigFromViteEnv);
|
|
92
104
|
}
|
|
93
105
|
// vite.config.js — lowest precedence. Merged into a *separate* result (used only to compute `root` and to
|
|
94
106
|
// find the Vike plugin): it must not flow back into `viteConfigUser`, which is handed to Vite —
|
|
@@ -126,6 +138,8 @@ async function resolve(viteContext) {
|
|
|
126
138
|
vikeVitePluginOptions = res.vikeVitePluginOptions;
|
|
127
139
|
}
|
|
128
140
|
assert(vikeVitePluginOptions);
|
|
141
|
+
if (debug.isActivated)
|
|
142
|
+
debug('viteConfigUser', viteConfigUser);
|
|
129
143
|
return { viteConfigUser, root, vikeVitePluginOptions };
|
|
130
144
|
}
|
|
131
145
|
function findVikeVitePlugin(viteConfig) {
|
|
@@ -79,26 +79,29 @@ function pluginCommon(vikeVitePluginOptions) {
|
|
|
79
79
|
config: {
|
|
80
80
|
order: 'post',
|
|
81
81
|
async handler(configFromUser) {
|
|
82
|
-
|
|
82
|
+
const configFromVike = { server: {}, preview: {} };
|
|
83
83
|
const vikeConfig = await getVikeConfigInternal();
|
|
84
|
+
// A value the user set through Vike (+config.js, CLI option, or VIKE_CONFIG) overrides vite.config.js:
|
|
85
|
+
// Vike's config has higher precedence than vite.config.js (see precedence list at resolveViteConfigUser.ts).
|
|
86
|
+
// Vike's own fallbacks (default port, Docker `--host`) use setDefault() so they don't override vite.config.js.
|
|
84
87
|
if (vikeConfig.config.port !== undefined) {
|
|
85
88
|
// https://vike.dev/port
|
|
86
|
-
|
|
89
|
+
setOverride('port', vikeConfig.config.port, configFromVike);
|
|
87
90
|
}
|
|
88
91
|
else {
|
|
89
92
|
// Change Vite's default port
|
|
90
93
|
setDefault('port', 3000, configFromUser, configFromVike);
|
|
91
94
|
}
|
|
92
|
-
if (vikeConfig.config.host) {
|
|
95
|
+
if (vikeConfig.config.host !== undefined) {
|
|
93
96
|
// https://vike.dev/host
|
|
94
|
-
|
|
97
|
+
setOverride('host', vikeConfig.config.host, configFromVike);
|
|
95
98
|
}
|
|
96
99
|
else if (isDocker()) {
|
|
97
100
|
// Set `--host` for Docker/Podman
|
|
98
101
|
setDefault('host', true, configFromUser, configFromVike);
|
|
99
102
|
}
|
|
100
103
|
// https://vike.dev/force
|
|
101
|
-
if (vikeConfig.config.force !== undefined
|
|
104
|
+
if (vikeConfig.config.force !== undefined) {
|
|
102
105
|
configFromVike.optimizeDeps ?? (configFromVike.optimizeDeps = {});
|
|
103
106
|
configFromVike.optimizeDeps.force = vikeConfig.config.force;
|
|
104
107
|
}
|
|
@@ -108,7 +111,12 @@ function pluginCommon(vikeVitePluginOptions) {
|
|
|
108
111
|
},
|
|
109
112
|
];
|
|
110
113
|
}
|
|
111
|
-
//
|
|
114
|
+
// Apply a Vike-provided value, overriding vite.config.js (Vike's config has higher precedence than vite.config.js)
|
|
115
|
+
function setOverride(setting, value, configFromVike) {
|
|
116
|
+
configFromVike.server[setting] = value;
|
|
117
|
+
configFromVike.preview[setting] = value;
|
|
118
|
+
}
|
|
119
|
+
// Apply a Vike fallback without overriding the user's vite.config.js
|
|
112
120
|
function setDefault(setting, value, configFromUser, configFromVike) {
|
|
113
121
|
if (configFromUser.server?.[setting] === undefined)
|
|
114
122
|
configFromVike.server[setting] = value;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PROJECT_VERSION: "0.4.259-commit-
|
|
1
|
+
export declare const PROJECT_VERSION: "0.4.259-commit-9fc8a01";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Automatically updated by @brillout/release-me
|
|
2
|
-
export const PROJECT_VERSION = '0.4.259-commit-
|
|
2
|
+
export const PROJECT_VERSION = '0.4.259-commit-9fc8a01';
|
package/dist/utils/debug.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export { createDebug };
|
|
|
2
2
|
export { isDebug };
|
|
3
3
|
export { isDebugError };
|
|
4
4
|
export { debug };
|
|
5
|
-
declare const flags: ["vike", "vike:config", "vike:crawl", "vike:file-change", "vike:error", "vike:esbuild-resolve", "vike:pluginExtractAssets", "vike:pluginExtractExportNames", "vike:glob", "vike:globalContext", "vike:log", "vike:optimizeDeps", "vike:outDir", "vike:pageFiles", "vike:pointer-imports", "vike:requireResolve", "vike:routing", "vike:setup", "vike:staticReplace", "vike:stream", "vike:virtualFiles", "vike:vite-rpc"];
|
|
5
|
+
declare const flags: ["vike", "vike:config", "vike:crawl", "vike:file-change", "vike:error", "vike:esbuild-resolve", "vike:pluginExtractAssets", "vike:pluginExtractExportNames", "vike:glob", "vike:globalContext", "vike:log", "vike:optimizeDeps", "vike:outDir", "vike:pageFiles", "vike:pointer-imports", "vike:requireResolve", "vike:routing", "vike:setup", "vike:staticReplace", "vike:stream", "vike:virtualFiles", "vike:vite-config-user", "vike:vite-rpc"];
|
|
6
6
|
type Flag = (typeof flags)[number];
|
|
7
7
|
type Options = {
|
|
8
8
|
serialization?: {
|
package/dist/utils/debug.js
CHANGED