vike 0.4.243-commit-0e44b70 → 0.4.243-commit-0d0395a
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.
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { preview };
|
|
2
|
+
export type { CliPreviewConfig };
|
|
2
3
|
import { type ResolvedConfig, type PreviewServer } from 'vite';
|
|
3
4
|
import type { ApiOptions } from './types.js';
|
|
4
5
|
/**
|
|
@@ -10,3 +11,5 @@ declare function preview(options?: ApiOptions): Promise<{
|
|
|
10
11
|
viteServer?: PreviewServer;
|
|
11
12
|
viteConfig: ResolvedConfig;
|
|
12
13
|
}>;
|
|
14
|
+
type CliPreviewValue = boolean | 'vite' | undefined;
|
|
15
|
+
type CliPreviewConfig = CliPreviewValue | (() => CliPreviewValue | Promise<CliPreviewValue>);
|
|
@@ -7,6 +7,7 @@ import { assertUsage, assertWarning, onSetupPreview } from './utils.js';
|
|
|
7
7
|
import pc from '@brillout/picocolors';
|
|
8
8
|
import path from 'node:path';
|
|
9
9
|
import { getVikeConfigInternal } from '../vite/shared/resolveVikeConfigInternal.js';
|
|
10
|
+
import { isCallable } from '../runtime/utils.js';
|
|
10
11
|
/**
|
|
11
12
|
* Programmatically trigger `$ vike preview`
|
|
12
13
|
*
|
|
@@ -15,8 +16,7 @@ import { getVikeConfigInternal } from '../vite/shared/resolveVikeConfigInternal.
|
|
|
15
16
|
async function preview(options = {}) {
|
|
16
17
|
onSetupPreview();
|
|
17
18
|
const { viteConfigFromUserResolved, viteConfigResolved } = await prepareViteApiCall(options, 'preview');
|
|
18
|
-
const
|
|
19
|
-
const cliPreview = vikeConfig.config.cli?.preview;
|
|
19
|
+
const cliPreview = await resolveCliPreviewConfig();
|
|
20
20
|
assertUsage(cliPreview !== false, `${pc.cyan('$ vike preview')} isn't supported`);
|
|
21
21
|
const useVite = cliPreview === 'vite' || (cliPreview === undefined && !viteConfigResolved.vitePluginServerEntry?.inject);
|
|
22
22
|
if (!useVite) {
|
|
@@ -38,3 +38,13 @@ async function preview(options = {}) {
|
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
+
async function resolveCliPreviewConfig() {
|
|
42
|
+
const vikeConfig = await getVikeConfigInternal();
|
|
43
|
+
const val = vikeConfig.config.cli?.preview;
|
|
44
|
+
if (!isCallable(val)) {
|
|
45
|
+
return val;
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
return await val();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -46,6 +46,7 @@ import type { PageContextClient, PageContextServer } from './PageContext.js';
|
|
|
46
46
|
import type { GlobalContext } from './GlobalContext.js';
|
|
47
47
|
import type { InlineConfig } from 'vite';
|
|
48
48
|
import type { PassToClientPublic } from '../node/runtime/renderPage/html/serializeContext.js';
|
|
49
|
+
import type { CliPreviewConfig } from '../node/api/preview.js';
|
|
49
50
|
type HookNameOld = HookName | HookNameOldDesign;
|
|
50
51
|
type HookName = HookNamePage | HookNameGlobal;
|
|
51
52
|
type HookNamePage = 'onHydrationEnd' | 'onBeforePrerenderStart' | 'onBeforeRender' | 'onPageTransitionStart' | 'onPageTransitionEnd' | 'onRenderHtml' | 'onRenderClient' | 'guard' | 'data' | 'onData' | 'route';
|
|
@@ -515,7 +516,7 @@ type ConfigBuiltIn = {
|
|
|
515
516
|
middleware?: Function;
|
|
516
517
|
/** @experimental */
|
|
517
518
|
cli?: {
|
|
518
|
-
preview?:
|
|
519
|
+
preview?: CliPreviewConfig;
|
|
519
520
|
};
|
|
520
521
|
};
|
|
521
522
|
type ConfigBuiltInResolved = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PROJECT_VERSION: "0.4.243-commit-
|
|
1
|
+
export declare const PROJECT_VERSION: "0.4.243-commit-0d0395a";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Automatically updated by @brillout/release-me
|
|
2
|
-
export const PROJECT_VERSION = '0.4.243-commit-
|
|
2
|
+
export const PROJECT_VERSION = '0.4.243-commit-0d0395a';
|