vike 0.4.215 → 0.4.217-commit-99ea561

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.
Files changed (144) hide show
  1. package/dist/cjs/__internal/index.js +2 -2
  2. package/dist/cjs/node/api/build.js +10 -3
  3. package/dist/cjs/node/api/context.js +8 -6
  4. package/dist/cjs/node/api/dev.js +7 -2
  5. package/dist/cjs/node/api/{prepareApiCall.js → prepareViteApiCall.js} +16 -6
  6. package/dist/cjs/node/api/prerender.js +7 -2
  7. package/dist/cjs/node/api/preview.js +7 -2
  8. package/dist/cjs/node/api/utils.js +1 -0
  9. package/dist/cjs/node/plugin/index.js +7 -10
  10. package/dist/cjs/node/plugin/onLoad.js +2 -2
  11. package/dist/cjs/node/plugin/plugins/autoFullBuild.js +15 -12
  12. package/dist/cjs/node/plugin/plugins/baseUrls.js +17 -12
  13. package/dist/cjs/node/plugin/plugins/buildConfig/fixServerAssets.js +1 -1
  14. package/dist/cjs/node/plugin/plugins/buildConfig.js +10 -10
  15. package/dist/cjs/node/plugin/plugins/commonConfig.js +35 -4
  16. package/dist/cjs/node/plugin/plugins/devConfig/determineOptimizeDeps.js +5 -5
  17. package/dist/cjs/node/plugin/plugins/devConfig/index.js +1 -4
  18. package/dist/cjs/node/plugin/plugins/extractAssetsPlugin.js +4 -7
  19. package/dist/cjs/node/plugin/plugins/importBuild/getVikeManifest.js +2 -2
  20. package/dist/cjs/node/plugin/plugins/importBuild/index.js +8 -6
  21. package/dist/cjs/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +8 -8
  22. package/dist/cjs/node/plugin/plugins/importUserCode/index.js +9 -13
  23. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +23 -106
  24. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveVikeConfigGlobal.js +128 -0
  25. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +42 -28
  26. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +3 -4
  27. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +1 -1
  28. package/dist/cjs/node/plugin/plugins/previewConfig.js +4 -4
  29. package/dist/cjs/node/plugin/plugins/setGlobalContext.js +35 -17
  30. package/dist/cjs/node/prerender/runPrerender.js +5 -7
  31. package/dist/cjs/node/prerender/utils.js +1 -1
  32. package/dist/cjs/node/runtime/globalContext.js +21 -13
  33. package/dist/cjs/node/runtime/index-common.js +3 -1
  34. package/dist/cjs/node/runtime/renderPage/renderPageAlreadyRouted.js +1 -1
  35. package/dist/cjs/node/runtime/renderPage.js +4 -2
  36. package/dist/cjs/node/runtime/utils.js +1 -2
  37. package/dist/cjs/node/runtime-dev/createDevMiddleware.js +25 -0
  38. package/dist/cjs/node/runtime-dev/index.js +32 -0
  39. package/dist/cjs/node/shared/resolveBase.js +41 -0
  40. package/dist/cjs/shared/page-configs/getConfigValueBuildTime.js +2 -2
  41. package/dist/cjs/shared/page-configs/serialize/serializeConfigValues.js +2 -2
  42. package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
  43. package/dist/cjs/utils/assertSetup.js +135 -0
  44. package/dist/cjs/utils/isDocker.js +2 -2
  45. package/dist/cjs/utils/requireResolve.js +2 -2
  46. package/dist/esm/__internal/index.js +2 -2
  47. package/dist/esm/node/api/build.d.ts +5 -0
  48. package/dist/esm/node/api/build.js +10 -3
  49. package/dist/esm/node/api/context.js +9 -7
  50. package/dist/esm/node/api/dev.d.ts +5 -0
  51. package/dist/esm/node/api/dev.js +7 -2
  52. package/dist/esm/node/api/prepareViteApiCall.d.ts +7 -0
  53. package/dist/esm/node/api/{prepareApiCall.js → prepareViteApiCall.js} +16 -6
  54. package/dist/esm/node/api/prerender.d.ts +5 -0
  55. package/dist/esm/node/api/prerender.js +7 -2
  56. package/dist/esm/node/api/preview.d.ts +5 -0
  57. package/dist/esm/node/api/preview.js +7 -2
  58. package/dist/esm/node/api/utils.d.ts +1 -0
  59. package/dist/esm/node/api/utils.js +1 -0
  60. package/dist/esm/node/cli/parseCli.d.ts +1 -1
  61. package/dist/esm/node/plugin/index.d.ts +3 -3
  62. package/dist/esm/node/plugin/index.js +6 -9
  63. package/dist/esm/node/plugin/onLoad.js +1 -1
  64. package/dist/esm/node/plugin/plugins/autoFullBuild.js +15 -12
  65. package/dist/esm/node/plugin/plugins/baseUrls.d.ts +2 -2
  66. package/dist/esm/node/plugin/plugins/baseUrls.js +17 -12
  67. package/dist/esm/node/plugin/plugins/buildConfig/fixServerAssets.js +1 -1
  68. package/dist/esm/node/plugin/plugins/buildConfig.js +11 -11
  69. package/dist/esm/node/plugin/plugins/commonConfig.d.ts +7 -1
  70. package/dist/esm/node/plugin/plugins/commonConfig.js +36 -5
  71. package/dist/esm/node/plugin/plugins/devConfig/determineOptimizeDeps.d.ts +1 -1
  72. package/dist/esm/node/plugin/plugins/devConfig/determineOptimizeDeps.js +5 -5
  73. package/dist/esm/node/plugin/plugins/devConfig/index.js +2 -5
  74. package/dist/esm/node/plugin/plugins/extractAssetsPlugin.js +4 -7
  75. package/dist/esm/node/plugin/plugins/importBuild/getVikeManifest.d.ts +3 -2
  76. package/dist/esm/node/plugin/plugins/importBuild/getVikeManifest.js +2 -2
  77. package/dist/esm/node/plugin/plugins/importBuild/index.js +8 -6
  78. package/dist/esm/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.d.ts +2 -2
  79. package/dist/esm/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +8 -8
  80. package/dist/esm/node/plugin/plugins/importUserCode/index.js +11 -15
  81. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.d.ts +1 -1
  82. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +23 -106
  83. package/dist/esm/{shared/ConfigVike.d.ts → node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveVikeConfigGlobal.d.ts} +14 -12
  84. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveVikeConfigGlobal.js +123 -0
  85. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.d.ts +8 -6
  86. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +43 -29
  87. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +3 -4
  88. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +1 -1
  89. package/dist/esm/node/plugin/plugins/previewConfig.js +5 -5
  90. package/dist/esm/node/plugin/plugins/setGlobalContext.d.ts +1 -1
  91. package/dist/esm/node/plugin/plugins/setGlobalContext.js +37 -19
  92. package/dist/esm/node/plugin/shared/getEnvVarObject.d.ts +1 -1
  93. package/dist/esm/node/prerender/runPrerender.js +6 -8
  94. package/dist/esm/node/prerender/utils.d.ts +1 -1
  95. package/dist/esm/node/prerender/utils.js +1 -1
  96. package/dist/esm/node/runtime/globalContext.d.ts +8 -4
  97. package/dist/esm/node/runtime/globalContext.js +22 -14
  98. package/dist/esm/node/runtime/index-common.d.ts +1 -0
  99. package/dist/esm/node/runtime/index-common.js +1 -0
  100. package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.js +1 -1
  101. package/dist/esm/node/runtime/renderPage.js +5 -3
  102. package/dist/esm/node/runtime/utils.d.ts +1 -2
  103. package/dist/esm/node/runtime/utils.js +1 -2
  104. package/dist/esm/node/runtime-dev/createDevMiddleware.d.ts +10 -0
  105. package/dist/esm/node/runtime-dev/createDevMiddleware.js +23 -0
  106. package/dist/esm/node/runtime-dev/index.d.ts +3 -0
  107. package/dist/esm/node/runtime-dev/index.js +6 -0
  108. package/dist/esm/node/shared/resolveBase.d.ts +11 -0
  109. package/dist/esm/node/shared/resolveBase.js +36 -0
  110. package/dist/esm/shared/page-configs/Config.d.ts +2 -2
  111. package/dist/esm/shared/page-configs/getConfigValueBuildTime.js +1 -1
  112. package/dist/esm/shared/page-configs/serialize/serializeConfigValues.js +1 -1
  113. package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
  114. package/dist/esm/utils/PROJECT_VERSION.js +1 -1
  115. package/dist/esm/utils/assertSetup.d.ts +20 -0
  116. package/dist/esm/utils/assertSetup.js +130 -0
  117. package/dist/esm/utils/isDocker.js +1 -1
  118. package/dist/esm/utils/projectInfo.d.ts +1 -1
  119. package/dist/esm/utils/requireResolve.js +1 -1
  120. package/package.json +1 -1
  121. package/dist/cjs/node/plugin/plugins/config/assertVikeConfig.js +0 -75
  122. package/dist/cjs/node/plugin/plugins/config/index.js +0 -81
  123. package/dist/cjs/node/plugin/plugins/config/pickFirst.js +0 -6
  124. package/dist/cjs/node/plugin/plugins/config/resolveBase.js +0 -47
  125. package/dist/cjs/node/shared/getConfigVike.js +0 -10
  126. package/dist/cjs/shared/ConfigVike.js +0 -2
  127. package/dist/cjs/utils/assertIsNotProductionRuntime.js +0 -62
  128. package/dist/cjs/utils/assertNodeEnv.js +0 -106
  129. package/dist/esm/node/api/prepareApiCall.d.ts +0 -7
  130. package/dist/esm/node/plugin/plugins/config/assertVikeConfig.d.ts +0 -7
  131. package/dist/esm/node/plugin/plugins/config/assertVikeConfig.js +0 -73
  132. package/dist/esm/node/plugin/plugins/config/index.d.ts +0 -3
  133. package/dist/esm/node/plugin/plugins/config/index.js +0 -76
  134. package/dist/esm/node/plugin/plugins/config/pickFirst.d.ts +0 -1
  135. package/dist/esm/node/plugin/plugins/config/pickFirst.js +0 -3
  136. package/dist/esm/node/plugin/plugins/config/resolveBase.d.ts +0 -10
  137. package/dist/esm/node/plugin/plugins/config/resolveBase.js +0 -42
  138. package/dist/esm/node/shared/getConfigVike.d.ts +0 -4
  139. package/dist/esm/node/shared/getConfigVike.js +0 -8
  140. package/dist/esm/shared/ConfigVike.js +0 -1
  141. package/dist/esm/utils/assertIsNotProductionRuntime.d.ts +0 -12
  142. package/dist/esm/utils/assertIsNotProductionRuntime.js +0 -59
  143. package/dist/esm/utils/assertNodeEnv.d.ts +0 -10
  144. package/dist/esm/utils/assertNodeEnv.js +0 -103
@@ -1,24 +1,27 @@
1
1
  export { crawlPlusFiles };
2
2
  import { assertPosixPath, assert, scriptFileExtensions, assertIsSingleModuleInstance, assertIsNotProductionRuntime, isVersionOrAbove, isScriptFile } from '../../../../utils.js';
3
3
  import path from 'path';
4
- import fs from 'fs/promises';
5
4
  import glob from 'fast-glob';
6
5
  import { exec } from 'child_process';
7
6
  import { promisify } from 'util';
8
7
  import { isTemporaryBuildFile } from './transpileAndExecuteFile.js';
8
+ import { getEnvVarObject } from '../../../../shared/getEnvVarObject.js';
9
9
  const execA = promisify(exec);
10
- const TOO_MANY_UNTRACKED_FILES = 5;
11
10
  assertIsNotProductionRuntime();
12
11
  assertIsSingleModuleInstance('crawlPlusFiles.ts');
13
12
  let gitIsNotUsable = false;
14
- async function crawlPlusFiles(userRootDir, outDirAbsoluteFilesystem, crawlWithGit) {
13
+ async function crawlPlusFiles(userRootDir, outDirAbsoluteFilesystem) {
15
14
  assertPosixPath(userRootDir);
16
- assertPosixPath(outDirAbsoluteFilesystem);
17
- let outDirRelativeFromUserRootDir = path.posix.relative(userRootDir, outDirAbsoluteFilesystem);
15
+ //*/
16
+ const outDirRelativeFromUserRootDir = null;
17
+ /*/
18
+ assertPosixPath(outDirAbsoluteFilesystem)
19
+ let outDirRelativeFromUserRootDir: string | null = path.posix.relative(userRootDir, outDirAbsoluteFilesystem)
18
20
  if (outDirRelativeFromUserRootDir.startsWith('../')) {
19
- // config.outDir is outside of config.root => it's going to be ignored anyways
20
- outDirRelativeFromUserRootDir = null;
21
+ // config.outDir is outside of config.root => it's going to be ignored anyways
22
+ outDirRelativeFromUserRootDir = null
21
23
  }
24
+ //*/
22
25
  assert(outDirRelativeFromUserRootDir === null ||
23
26
  /* Not true if outDirRelativeFromUserRootDir starts with a hidden directory (i.e. a directory with a name that starts with `.`)
24
27
  !outDirRelativeFromUserRootDir.startsWith('.') &&
@@ -27,14 +30,13 @@ async function crawlPlusFiles(userRootDir, outDirAbsoluteFilesystem, crawlWithGi
27
30
  //
28
31
  !outDirRelativeFromUserRootDir.startsWith('../')));
29
32
  // Crawl
30
- let files = [];
31
- const res = crawlWithGit !== false && (await gitLsFiles(userRootDir, outDirRelativeFromUserRootDir));
33
+ let files;
34
+ const res = !isGitCrawlDisabled() && (await gitLsFiles(userRootDir, outDirRelativeFromUserRootDir));
32
35
  if (res &&
33
36
  // Fallback to fast-glob for users that dynamically generate plus files. (Assuming that no plus file is found because of the user's .gitignore list.)
34
- res.files.length > 0) {
35
- files = res.files;
37
+ res.length > 0) {
38
+ files = res;
36
39
  // We cannot find files inside symlink directories with `$ git ls-files` => we use fast-glob
37
- files.push(...(await crawlSymlinkDirs(res.symlinkDirs, userRootDir, outDirRelativeFromUserRootDir)));
38
40
  }
39
41
  else {
40
42
  files = await fastGlob(userRootDir, outDirRelativeFromUserRootDir);
@@ -76,14 +78,13 @@ async function gitLsFiles(userRootDir, outDirRelativeFromUserRootDir) {
76
78
  ...ignoreAsPatterns.map((pattern) => `--exclude="${pattern}"`),
77
79
  // --others --exclude-standard => list untracked files (--others) while using .gitignore (--exclude-standard)
78
80
  // --cached => list tracked files
79
- // --stage => get file modes which we use to find symlink directories
80
- '--others --exclude-standard --cached --stage'
81
+ '--others --exclude-standard --cached'
81
82
  ].join(' ');
82
- let resultLines;
83
+ let filesAll;
83
84
  let filesDeleted;
84
85
  try {
85
86
  ;
86
- [resultLines, filesDeleted] = await Promise.all([
87
+ [filesAll, filesDeleted] = await Promise.all([
87
88
  // Main command
88
89
  runCmd1(cmd, userRootDir),
89
90
  // Get tracked but deleted files
@@ -97,31 +98,14 @@ async function gitLsFiles(userRootDir, outDirRelativeFromUserRootDir) {
97
98
  }
98
99
  throw err;
99
100
  }
100
- const filePaths = resultLines.map(parseGitLsResultLine);
101
- // If there are too many files without mode we fallback to fast-glob
102
- if (filePaths.filter((f) => !f.mode).length > TOO_MANY_UNTRACKED_FILES)
103
- return null;
104
- const symlinkDirs = [];
105
101
  const files = [];
106
- for (const { filePath, mode } of filePaths) {
102
+ for (const filePath of filesAll) {
107
103
  // Deleted?
108
104
  if (filesDeleted.includes(filePath))
109
105
  continue;
110
106
  // We have to repeat the same exclusion logic here because the option --exclude of `$ git ls-files` only applies to untracked files. (We use --exclude only to speed up the `$ git ls-files` command.)
111
107
  if (!ignoreAsFilterFn(filePath))
112
108
  continue;
113
- // Symlink directory?
114
- {
115
- const isSymlinkDir = await isSymlinkDirectory(mode, filePath, userRootDir);
116
- if (isSymlinkDir) {
117
- symlinkDirs.push(filePath);
118
- continue;
119
- }
120
- // Skip deleted files and non-symlink directories
121
- if (isSymlinkDir === null) {
122
- continue;
123
- }
124
- }
125
109
  // + file?
126
110
  if (!path.posix.basename(filePath).startsWith('+'))
127
111
  continue;
@@ -130,7 +114,7 @@ async function gitLsFiles(userRootDir, outDirRelativeFromUserRootDir) {
130
114
  continue;
131
115
  files.push(filePath);
132
116
  }
133
- return { files, symlinkDirs };
117
+ return files;
134
118
  }
135
119
  // Same as gitLsFiles() but using fast-glob
136
120
  async function fastGlob(userRootDir, outDirRelativeFromUserRootDir) {
@@ -200,77 +184,6 @@ async function isGitNotUsable(userRootDir) {
200
184
  return false;
201
185
  }
202
186
  }
203
- async function crawlSymlinkDirs(symlinkDirs, userRootDir, outDirRelativeFromUserRootDir) {
204
- const filesInSymlinkDirs = (await Promise.all(symlinkDirs.map(async (symlinkDir) => (await fastGlob(path.posix.join(userRootDir, symlinkDir), outDirRelativeFromUserRootDir)).map((filePath) => path.posix.join(symlinkDir, filePath))))).flat();
205
- return filesInSymlinkDirs;
206
- }
207
- // Parse:
208
- // ```
209
- // some/not/tracked/path
210
- // 100644 f6928073402b241b468b199893ff6f4aed0b7195 0\tpages/index/+Page.tsx
211
- // ```
212
- function parseGitLsResultLine(resultLine) {
213
- const [part1, part2, ...rest] = resultLine.split('\t');
214
- assert(part1);
215
- assert(rest.length === 0);
216
- // Git doesn't provide the mode for untracked paths.
217
- // `resultLine` is:
218
- // ```
219
- // some/not/tracked/path
220
- // ```
221
- if (part2 === undefined) {
222
- return { filePath: part1, mode: null };
223
- }
224
- assert(part2);
225
- // `resultLine` is:
226
- // ```
227
- // 100644 f6928073402b241b468b199893ff6f4aed0b7195 0\tpages/index/+Page.tsx
228
- // ```
229
- const [mode, _, __, ...rest2] = part1.split(' ');
230
- assert(mode && _ && __ && rest2.length === 0);
231
- return { filePath: part2, mode };
232
- }
233
- async function isSymlinkDirectory(mode, filePath, userRootDir) {
234
- const filePathAbsolute = path.posix.join(userRootDir, filePath);
235
- let stats = null;
236
- let isSymlink = false;
237
- if (mode === '120000') {
238
- isSymlink = true;
239
- }
240
- else if (mode === null) {
241
- // `$ git ls-files` doesn't provide the mode when Git doesn't track the path
242
- stats = await getFileStats(filePathAbsolute);
243
- if (stats === null)
244
- return null;
245
- isSymlink = stats.isSymbolicLink();
246
- if (!isSymlink && stats.isDirectory())
247
- return null;
248
- }
249
- else {
250
- assert(mode);
251
- }
252
- if (!isSymlink)
253
- return false;
254
- if (!stats)
255
- stats = await getFileStats(filePathAbsolute);
256
- if (stats === null)
257
- return null;
258
- const isDirectory = stats.isDirectory();
259
- return isDirectory;
260
- }
261
- async function getFileStats(filePathAbsolute) {
262
- let stats;
263
- try {
264
- stats = await fs.lstat(filePathAbsolute);
265
- }
266
- catch (err) {
267
- // File was deleted, usually a temporary file such as +config.js.build-j95xb988fpln.mjs
268
- // ENOENT: no such file or directory
269
- assert(err.code === 'ENOENT');
270
- return null;
271
- }
272
- return stats;
273
- }
274
187
  async function runCmd1(cmd, cwd) {
275
188
  const { stdout } = await execA(cmd, {
276
189
  cwd,
@@ -295,3 +208,7 @@ async function runCmd2(cmd, cwd) {
295
208
  stderr = stderr.toString().trim();
296
209
  return { stdout, stderr };
297
210
  }
211
+ function isGitCrawlDisabled() {
212
+ const crawSettings = getEnvVarObject('VIKE_CRAWL');
213
+ return crawSettings?.git === false;
214
+ }
@@ -1,6 +1,8 @@
1
- export type { ConfigVikeUserProvided };
2
- export type { ConfigVikeResolved };
3
- type ConfigVikeResolved = {
1
+ export { resolveVikeConfigGlobal };
2
+ export type { VikeConfigGlobal };
3
+ export type { VikeVitePluginOptions };
4
+ declare function resolveVikeConfigGlobal(vikeVitePluginOptions: unknown, pageConfigGlobalValues: Record<string, unknown>): VikeConfigGlobal;
5
+ type VikeConfigGlobal = {
4
6
  prerender: false | {
5
7
  noExtraDir: boolean;
6
8
  parallel: boolean | number;
@@ -9,8 +11,8 @@ type ConfigVikeResolved = {
9
11
  };
10
12
  disableAutoFullBuild: boolean | 'prerender' | null;
11
13
  includeAssetsImportedByServer: boolean;
12
- baseAssets: string;
13
- baseServer: string;
14
+ baseAssets: string | null;
15
+ baseServer: string | null;
14
16
  redirects: Record<string, string>;
15
17
  trailingSlash: boolean;
16
18
  disableUrlNormalization: boolean;
@@ -18,7 +20,7 @@ type ConfigVikeResolved = {
18
20
  git: null | boolean;
19
21
  };
20
22
  };
21
- type ConfigVikeUserProvided = {
23
+ type VikeVitePluginOptions = {
22
24
  /**
23
25
  * Enable pre-rendering.
24
26
  *
@@ -44,12 +46,12 @@ type ConfigVikeUserProvided = {
44
46
  */
45
47
  parallel?: boolean | number;
46
48
  /**
47
- * Allow only some of your pages to be pre-rendered.
48
- *
49
- * This setting doesn't affect the pre-rendering process: it merely suppresses the warnings when some of your pages cannot be pre-rendered.
50
-
51
- * @default false
52
- */
49
+ * Allow only some of your pages to be pre-rendered.
50
+ *
51
+ * This setting doesn't affect the pre-rendering process: it merely suppresses the warnings when some of your pages cannot be pre-rendered.
52
+
53
+ * @default false
54
+ */
53
55
  partial?: boolean;
54
56
  /**
55
57
  * Disable the automatic initiation of the pre-rendering process when running `$ vike build`.
@@ -0,0 +1,123 @@
1
+ export { resolveVikeConfigGlobal };
2
+ import pc from '@brillout/picocolors';
3
+ import { assert, assertUsage, hasProp, isObject } from '../../../../utils.js';
4
+ function resolveVikeConfigGlobal(vikeVitePluginOptions, pageConfigGlobalValues) {
5
+ // TODO/v1-release: remove
6
+ assertVikeConfigGlobal(vikeVitePluginOptions, ({ prop, errMsg }) => `vite.config.js > vike option ${prop} ${errMsg}`);
7
+ const configs = [vikeVitePluginOptions];
8
+ assertVikeConfigGlobal(pageConfigGlobalValues, ({ prop, errMsg }) => {
9
+ // Can we add the config file path ?
10
+ return `config ${pc.cyan(prop)} ${errMsg}`;
11
+ });
12
+ configs.push(pageConfigGlobalValues);
13
+ const vikeConfigGlobal = {
14
+ disableAutoFullBuild: pickFirst(configs.map((c) => c.disableAutoFullBuild)) ?? null,
15
+ prerender: resolvePrerenderOptions(configs),
16
+ includeAssetsImportedByServer: pickFirst(configs.map((c) => c.includeAssetsImportedByServer)) ?? true,
17
+ baseServer: pickFirst(configs.map((c) => c.baseServer)) ?? null,
18
+ baseAssets: pickFirst(configs.map((c) => c.baseAssets)) ?? null,
19
+ redirects: merge(configs.map((c) => c.redirects)) ?? {},
20
+ disableUrlNormalization: pickFirst(configs.map((c) => c.disableUrlNormalization)) ?? false,
21
+ trailingSlash: pickFirst(configs.map((c) => c.trailingSlash)) ?? false,
22
+ crawl: {
23
+ git: vikeVitePluginOptions.crawl?.git ?? null
24
+ }
25
+ };
26
+ return vikeConfigGlobal;
27
+ }
28
+ function resolvePrerenderOptions(configs) {
29
+ if (!configs.some((c) => c.prerender)) {
30
+ return false;
31
+ }
32
+ const configsPrerender = configs.map((c) => c.prerender).filter(isObject2);
33
+ return {
34
+ partial: pickFirst(configsPrerender.map((c) => c.partial)) ?? false,
35
+ noExtraDir: pickFirst(configsPrerender.map((c) => c.noExtraDir)) ?? false,
36
+ parallel: pickFirst(configsPrerender.map((c) => c.parallel)) ?? true,
37
+ disableAutoRun: pickFirst(configsPrerender.map((c) => c.disableAutoRun)) ?? false
38
+ };
39
+ }
40
+ function isObject2(p) {
41
+ return typeof p === 'object';
42
+ }
43
+ function merge(objs) {
44
+ const obj = {};
45
+ objs.forEach((e) => {
46
+ Object.assign(obj, e);
47
+ });
48
+ return obj;
49
+ }
50
+ function pickFirst(arr) {
51
+ return arr.filter((v) => v !== undefined)[0];
52
+ }
53
+ function assertVikeConfigGlobal(vikeConfigGlobal, wrongUsageMsg) {
54
+ const wrongUsageError = check(vikeConfigGlobal);
55
+ if (wrongUsageError) {
56
+ assertUsage(false, wrongUsageMsg(wrongUsageError));
57
+ }
58
+ }
59
+ function check(vikeConfigGlobal) {
60
+ assert(isObject(vikeConfigGlobal));
61
+ {
62
+ const prop = 'disableUrlNormalization';
63
+ if (!hasProp(vikeConfigGlobal, prop, 'boolean') && !hasProp(vikeConfigGlobal, prop, 'undefined'))
64
+ return { prop, errMsg: 'should be a boolean' };
65
+ }
66
+ {
67
+ const prop = 'trailingSlash';
68
+ if (!hasProp(vikeConfigGlobal, prop, 'boolean') && !hasProp(vikeConfigGlobal, prop, 'undefined'))
69
+ return { prop, errMsg: 'should be a boolean' };
70
+ }
71
+ {
72
+ const prop = 'redirects';
73
+ const { redirects } = vikeConfigGlobal;
74
+ if (!(redirects === undefined ||
75
+ (isObject(redirects) && Object.values(redirects).every((v) => typeof v === 'string'))))
76
+ return { prop, errMsg: 'should be an object of strings' };
77
+ }
78
+ {
79
+ const prop = 'disableAutoFullBuild';
80
+ if (!hasProp(vikeConfigGlobal, prop, 'boolean') &&
81
+ !hasProp(vikeConfigGlobal, prop, 'undefined') &&
82
+ !(vikeConfigGlobal[prop] === 'prerender'))
83
+ return { prop, errMsg: "should be a boolean or 'prerender'" };
84
+ }
85
+ {
86
+ const prop = 'includeAssetsImportedByServer';
87
+ if (!hasProp(vikeConfigGlobal, prop, 'boolean') && !hasProp(vikeConfigGlobal, prop, 'undefined'))
88
+ return { prop, errMsg: 'should be a boolean' };
89
+ }
90
+ {
91
+ const prop = 'prerender';
92
+ if (!hasProp(vikeConfigGlobal, prop, 'object') &&
93
+ !hasProp(vikeConfigGlobal, prop, 'boolean') &&
94
+ !hasProp(vikeConfigGlobal, prop, 'undefined'))
95
+ return { prop, errMsg: 'should be an object or a boolean' };
96
+ }
97
+ const configVikePrerender = vikeConfigGlobal.prerender;
98
+ if (typeof configVikePrerender === 'object') {
99
+ {
100
+ const p = 'partial';
101
+ if (!hasProp(configVikePrerender, p, 'boolean') && !hasProp(configVikePrerender, p, 'undefined'))
102
+ return { prop: `prerender.${p}`, errMsg: 'should be a boolean' };
103
+ }
104
+ {
105
+ const p = 'noExtraDir';
106
+ if (!hasProp(configVikePrerender, p, 'boolean') && !hasProp(configVikePrerender, p, 'undefined'))
107
+ return { prop: `prerender.${p}`, errMsg: 'should be a boolean' };
108
+ }
109
+ {
110
+ const p = 'disableAutoRun';
111
+ if (!hasProp(configVikePrerender, p, 'boolean') && !hasProp(configVikePrerender, p, 'undefined'))
112
+ return { prop: `prerender.${p}`, errMsg: 'should be a boolean' };
113
+ }
114
+ {
115
+ const p = 'parallel';
116
+ if (!hasProp(configVikePrerender, p, 'boolean') &&
117
+ !hasProp(configVikePrerender, p, 'number') &&
118
+ !hasProp(configVikePrerender, p, 'undefined'))
119
+ return { prop: `prerender.${p}`, errMsg: 'should be a boolean or a number' };
120
+ }
121
+ }
122
+ return null;
123
+ }
@@ -1,4 +1,5 @@
1
1
  export { getVikeConfig };
2
+ export { getVikeConfig2 };
2
3
  export { reloadVikeConfig };
3
4
  export { vikeConfigDependencies };
4
5
  export { isVikeConfigFile };
@@ -11,6 +12,7 @@ import type { PageConfigGlobalBuildTime, PageConfigBuildTime } from '../../../..
11
12
  import { type LocationId } from './getVikeConfig/filesystemRouting.js';
12
13
  import type { ResolvedConfig } from 'vite';
13
14
  import type { FilePathResolved } from '../../../../../shared/page-configs/FilePath.js';
15
+ import type { VikeConfigGlobal } from './getVikeConfig/resolveVikeConfigGlobal.js';
14
16
  type InterfaceFile = InterfaceConfigFile | InterfaceValueFile;
15
17
  type InterfaceFileCommons = {
16
18
  locationId: LocationId;
@@ -34,14 +36,14 @@ type ConfigName = string;
34
36
  type VikeConfigObject = {
35
37
  pageConfigs: PageConfigBuildTime[];
36
38
  pageConfigGlobal: PageConfigGlobalBuildTime;
37
- globalVikeConfig: Record<string, unknown>;
39
+ vikeConfigGlobal: VikeConfigGlobal;
38
40
  };
39
41
  declare const vikeConfigDependencies: Set<string>;
40
- declare function reloadVikeConfig(userRootDir: string, outDirRoot: string): void;
41
- declare function getVikeConfig(config: ResolvedConfig, isDev: boolean, { crawlWithGit, tolerateInvalidConfig }?: {
42
- crawlWithGit?: null | boolean;
43
- tolerateInvalidConfig?: true;
42
+ declare function reloadVikeConfig(config: ResolvedConfig): void;
43
+ declare function getVikeConfig(config: ResolvedConfig, { doNotRestartViteOnError }?: {
44
+ doNotRestartViteOnError?: true;
44
45
  }): Promise<VikeConfigObject>;
45
- declare function isV1Design(config: ResolvedConfig, isDev: boolean): Promise<boolean>;
46
+ declare function getVikeConfig2(userRootDir: string, isDev: boolean, vikeVitePluginOptions: unknown): Promise<VikeConfigObject>;
47
+ declare function isV1Design(config: ResolvedConfig): Promise<boolean>;
46
48
  declare function isVikeConfigFile(filePath: string): boolean;
47
49
  declare function getConfigValueInterfaceFile(interfaceFile: InterfaceFile, configName: string): unknown;
@@ -1,10 +1,11 @@
1
1
  export { getVikeConfig };
2
+ export { getVikeConfig2 };
2
3
  export { reloadVikeConfig };
3
4
  export { vikeConfigDependencies };
4
5
  export { isVikeConfigFile };
5
6
  export { isV1Design };
6
7
  export { getConfigValueInterfaceFile };
7
- import { assertPosixPath, assert, isObject, assertUsage, assertWarning, objectEntries, hasProp, includes, assertIsNotProductionRuntime, getMostSimilar, joinEnglish, lowerFirst, getOutDirs, assertKeys, objectKeys, objectFromEntries, makeFirst, isNpmPackageImport, reverse } from '../../../utils.js';
8
+ import { assertPosixPath, assert, isObject, assertUsage, assertWarning, objectEntries, hasProp, includes, assertIsNotProductionRuntime, getMostSimilar, joinEnglish, lowerFirst, assertKeys, objectKeys, objectFromEntries, makeFirst, isNpmPackageImport, reverse } from '../../../utils.js';
8
9
  import path from 'path';
9
10
  import { configDefinitionsBuiltIn, configDefinitionsBuiltInGlobal } from './getVikeConfig/configDefinitionsBuiltIn.js';
10
11
  import { getLocationId, getFilesystemRouteString, getFilesystemRouteDefinedBy, isInherited, sortAfterInheritanceOrder, isGlobalLocation, applyFilesystemRoutingRootEffect } from './getVikeConfig/filesystemRouting.js';
@@ -21,17 +22,20 @@ import { loadConfigFile, loadImportedFile, loadValueFile } from './getVikeConfig
21
22
  import { clearFilesEnvMap, resolveConfigEnvWithFileName, resolvePointerImportOfConfig } from './getVikeConfig/resolvePointerImport.js';
22
23
  import { getFilePathResolved } from '../../../shared/getFilePath.js';
23
24
  import { getConfigValueBuildTime } from '../../../../../shared/page-configs/getConfigValueBuildTime.js';
24
- import { getConfigVike } from '../../../../shared/getConfigVike.js';
25
25
  import { assertExtensionsPeerDependencies, assertExtensionsConventions } from './assertExtensions.js';
26
+ import { resolveVikeConfigGlobal } from './getVikeConfig/resolveVikeConfigGlobal.js';
26
27
  assertIsNotProductionRuntime();
27
- let devServerIsCorrupt = false;
28
+ let restartVite = false;
28
29
  let wasConfigInvalid = null;
29
30
  let vikeConfigPromise = null;
30
31
  const vikeConfigDependencies = new Set();
31
- function reloadVikeConfig(userRootDir, outDirRoot) {
32
+ function reloadVikeConfig(config) {
33
+ const userRootDir = config.root;
34
+ const vikeVitePluginOptions = config._vikeVitePluginOptions;
35
+ assert(vikeVitePluginOptions);
32
36
  vikeConfigDependencies.clear();
33
37
  clearFilesEnvMap();
34
- vikeConfigPromise = loadVikeConfig_withErrorHandling(userRootDir, outDirRoot, true, true);
38
+ vikeConfigPromise = loadVikeConfig_withErrorHandling(userRootDir, true, vikeVitePluginOptions);
35
39
  handleReloadSideEffects();
36
40
  }
37
41
  async function handleReloadSideEffects() {
@@ -55,8 +59,8 @@ async function handleReloadSideEffects() {
55
59
  wasConfigInvalid = false;
56
60
  logConfigErrorRecover();
57
61
  }
58
- if (devServerIsCorrupt) {
59
- devServerIsCorrupt = false;
62
+ if (restartVite) {
63
+ restartVite = false;
60
64
  const viteDevServer = getViteDevServer();
61
65
  assert(viteDevServer);
62
66
  removeSuperfluousViteLog_enable();
@@ -65,23 +69,32 @@ async function handleReloadSideEffects() {
65
69
  }
66
70
  }
67
71
  }
68
- async function getVikeConfig(config, isDev, { crawlWithGit, tolerateInvalidConfig } = {}) {
69
- const { outDirRoot } = getOutDirs(config);
72
+ async function getVikeConfig(config, { doNotRestartViteOnError } = {}) {
70
73
  const userRootDir = config.root;
74
+ const vikeVitePluginOptions = config._vikeVitePluginOptions;
75
+ assert(vikeVitePluginOptions);
76
+ const isDev = config._isDev;
77
+ assert(typeof isDev === 'boolean');
78
+ return await getVikeConfigEntry(userRootDir, isDev, vikeVitePluginOptions, doNotRestartViteOnError ?? false);
79
+ }
80
+ async function getVikeConfig2(userRootDir, isDev, vikeVitePluginOptions) {
81
+ assert(vikeVitePluginOptions);
82
+ return await getVikeConfigEntry(userRootDir, isDev, vikeVitePluginOptions, false);
83
+ }
84
+ async function getVikeConfigEntry(userRootDir, isDev, vikeVitePluginOptions, doNotRestartViteOnError) {
71
85
  if (!vikeConfigPromise) {
72
- const crawlWithGit_ = crawlWithGit !== undefined ? crawlWithGit : (await getConfigVike(config)).crawl.git;
73
- vikeConfigPromise = loadVikeConfig_withErrorHandling(userRootDir, outDirRoot, isDev, crawlWithGit_, tolerateInvalidConfig);
86
+ vikeConfigPromise = loadVikeConfig_withErrorHandling(userRootDir, isDev, vikeVitePluginOptions, doNotRestartViteOnError);
74
87
  }
75
88
  return await vikeConfigPromise;
76
89
  }
77
- async function isV1Design(config, isDev) {
78
- const vikeConfig = await getVikeConfig(config, isDev);
90
+ async function isV1Design(config) {
91
+ const vikeConfig = await getVikeConfig(config);
79
92
  const { pageConfigs } = vikeConfig;
80
93
  const isV1Design = pageConfigs.length > 0;
81
94
  return isV1Design;
82
95
  }
83
- async function loadInterfaceFiles(userRootDir, outDirRoot, crawlWithGit) {
84
- const plusFiles = await findPlusFiles(userRootDir, outDirRoot, crawlWithGit);
96
+ async function loadInterfaceFiles(userRootDir) {
97
+ const plusFiles = await findPlusFiles(userRootDir, null);
85
98
  const configFiles = [];
86
99
  const valueFiles = [];
87
100
  plusFiles.forEach((f) => {
@@ -190,12 +203,12 @@ function assertAllConfigsAreKnown(interfaceFilesByLocationId) {
190
203
  });
191
204
  });
192
205
  }
193
- async function loadVikeConfig_withErrorHandling(userRootDir, outDirRoot, isDev, crawlWithGit, tolerateInvalidConfig) {
206
+ async function loadVikeConfig_withErrorHandling(userRootDir, isDev, vikeVitePluginOptions, doNotRestartViteOnError) {
194
207
  let hasError = false;
195
208
  let ret;
196
209
  let err;
197
210
  try {
198
- ret = await loadVikeConfig(userRootDir, outDirRoot, crawlWithGit);
211
+ ret = await loadVikeConfig(userRootDir, vikeVitePluginOptions);
199
212
  }
200
213
  catch (err_) {
201
214
  hasError = true;
@@ -217,8 +230,8 @@ async function loadVikeConfig_withErrorHandling(userRootDir, outDirRoot, isDev,
217
230
  }
218
231
  else {
219
232
  logConfigError(err);
220
- if (!tolerateInvalidConfig) {
221
- devServerIsCorrupt = true;
233
+ if (!doNotRestartViteOnError) {
234
+ restartVite = true;
222
235
  }
223
236
  const dummyData = {
224
237
  pageConfigs: [],
@@ -226,16 +239,17 @@ async function loadVikeConfig_withErrorHandling(userRootDir, outDirRoot, isDev,
226
239
  configDefinitions: {},
227
240
  configValueSources: {}
228
241
  },
229
- globalVikeConfig: {}
242
+ vikeConfigGlobal: resolveVikeConfigGlobal({}, {})
230
243
  };
231
244
  return dummyData;
232
245
  }
233
246
  }
234
247
  }
235
- async function loadVikeConfig(userRootDir, outDirRoot, crawlWithGit) {
236
- const interfaceFilesByLocationId = await loadInterfaceFiles(userRootDir, outDirRoot, crawlWithGit);
248
+ async function loadVikeConfig(userRootDir, vikeVitePluginOptions) {
249
+ const interfaceFilesByLocationId = await loadInterfaceFiles(userRootDir);
237
250
  const importedFilesLoaded = {};
238
- const { globalVikeConfig, pageConfigGlobal } = await getGlobalConfigs(interfaceFilesByLocationId, userRootDir, importedFilesLoaded);
251
+ const { pageConfigGlobal, pageConfigGlobalValues } = await getGlobalConfigs(interfaceFilesByLocationId, userRootDir, importedFilesLoaded);
252
+ const vikeConfigGlobal = resolveVikeConfigGlobal(vikeVitePluginOptions, pageConfigGlobalValues);
239
253
  const pageConfigs = await Promise.all(objectEntries(interfaceFilesByLocationId)
240
254
  .filter(([_pageId, interfaceFiles]) => isDefiningPage(interfaceFiles))
241
255
  .map(async ([locationId]) => {
@@ -285,7 +299,7 @@ async function loadVikeConfig(userRootDir, outDirRoot, crawlWithGit) {
285
299
  return pageConfig;
286
300
  }));
287
301
  assertPageConfigs(pageConfigs);
288
- return { pageConfigs, pageConfigGlobal, globalVikeConfig };
302
+ return { pageConfigs, pageConfigGlobal, vikeConfigGlobal };
289
303
  }
290
304
  // TODO/soon: refactor
291
305
  // - Dedupe: most of the assertUsageGlobalConfigs() code below is a copy-paste of the assertUsage() logic inside getGlobalConfigs()
@@ -395,7 +409,7 @@ async function getGlobalConfigs(interfaceFilesByLocationId, userRootDir, importe
395
409
  });
396
410
  });
397
411
  }
398
- const globalVikeConfig = {};
412
+ const pageConfigGlobalValues = {};
399
413
  const pageConfigGlobal = {
400
414
  configDefinitions: configDefinitionsBuiltInGlobal,
401
415
  configValueSources: {}
@@ -415,10 +429,10 @@ async function getGlobalConfigs(interfaceFilesByLocationId, userRootDir, importe
415
429
  return;
416
430
  const { filePathToShowToUser } = configValueSource.definedAtFilePath;
417
431
  assertWarning(false, `Being able to define config ${pc.cyan(configName)} in ${filePathToShowToUser} is experimental and will likely be removed. Define the config ${pc.cyan(configName)} in Vike's Vite plugin options instead.`, { onlyOnce: true });
418
- globalVikeConfig[configName] = configValueSource.value;
432
+ pageConfigGlobalValues[configName] = configValueSource.value;
419
433
  }
420
434
  }));
421
- return { pageConfigGlobal, globalVikeConfig };
435
+ return { pageConfigGlobal, pageConfigGlobalValues };
422
436
  }
423
437
  async function resolveConfigValueSources(configName, configDef, interfaceFilesRelevant, userRootDir, importedFilesLoaded) {
424
438
  const sourcesInfo = [];
@@ -779,8 +793,8 @@ function getComputed(configValueSources, configDefinitions) {
779
793
  });
780
794
  return configValuesComputed;
781
795
  }
782
- async function findPlusFiles(userRootDir, outDirRoot, crawlWithGit) {
783
- const files = await crawlPlusFiles(userRootDir, outDirRoot, crawlWithGit);
796
+ async function findPlusFiles(userRootDir, outDirRoot) {
797
+ const files = await crawlPlusFiles(userRootDir, outDirRoot);
784
798
  const plusFiles = files.map(({ filePathAbsoluteUserRootDir }) => getFilePathResolved({ filePathAbsoluteUserRootDir, userRootDir }));
785
799
  return plusFiles;
786
800
  }
@@ -6,7 +6,6 @@ import { extractAssetsAddQuery } from '../../../../shared/extractAssetsQuery.js'
6
6
  import { debug } from './debug.js';
7
7
  import { isRuntimeEnvMatch } from './isRuntimeEnvMatch.js';
8
8
  import { serializeConfigValues } from '../../../../../shared/page-configs/serialize/serializeConfigValues.js';
9
- import { getConfigVike } from '../../../../shared/getConfigVike.js';
10
9
  import { fixServerAssets_isEnabled } from '../../buildConfig/fixServerAssets.js';
11
10
  import { getConfigValueBuildTime } from '../../../../../shared/page-configs/getConfigValueBuildTime.js';
12
11
  async function getVirtualFilePageConfigValuesAll(id, isDev, config) {
@@ -19,11 +18,11 @@ async function getVirtualFilePageConfigValuesAll(id, isDev, config) {
19
18
  }
20
19
  */
21
20
  const { pageId, isForClientSide } = result;
22
- const { pageConfigs } = await getVikeConfig(config, isDev, { tolerateInvalidConfig: true });
21
+ const vikeConfig = await getVikeConfig(config, { doNotRestartViteOnError: true });
22
+ const { pageConfigs } = vikeConfig;
23
23
  const pageConfig = pageConfigs.find((pageConfig) => pageConfig.pageId === pageId);
24
24
  assert(pageConfig, { id, pageId });
25
- const configVike = await getConfigVike(config);
26
- const code = getLoadConfigValuesAll(pageConfig, isForClientSide, pageId, configVike.includeAssetsImportedByServer, isDev);
25
+ const code = getLoadConfigValuesAll(pageConfig, isForClientSide, pageId, vikeConfig.vikeConfigGlobal.includeAssetsImportedByServer, isDev);
27
26
  debug(id, isForClientSide ? 'CLIENT-SIDE' : 'SERVER-SIDE', code);
28
27
  return code;
29
28
  }
@@ -5,7 +5,7 @@ import { getVikeConfig } from './getVikeConfig.js';
5
5
  import { isRuntimeEnvMatch } from './isRuntimeEnvMatch.js';
6
6
  import { serializeConfigValues } from '../../../../../shared/page-configs/serialize/serializeConfigValues.js';
7
7
  async function getVirtualFilePageConfigs(isForClientSide, isDev, id, isClientRouting, config) {
8
- const { pageConfigs, pageConfigGlobal } = await getVikeConfig(config, isDev, { tolerateInvalidConfig: true });
8
+ const { pageConfigs, pageConfigGlobal } = await getVikeConfig(config, { doNotRestartViteOnError: true });
9
9
  return getCode(pageConfigs, pageConfigGlobal, isForClientSide, isDev, id, isClientRouting);
10
10
  }
11
11
  function getCode(pageConfigs, pageConfigGlobal, isForClientSide, isDev, id, isClientRouting) {
@@ -1,5 +1,5 @@
1
1
  export { previewConfig };
2
- import { assertUsage, getOutDirs, resolveOutDir, markEnvAsVitePreview, applyPreview } from '../utils.js';
2
+ import { assertUsage, getOutDirs, resolveOutDir, applyPreview } from '../utils.js';
3
3
  import fs from 'fs';
4
4
  import path from 'path';
5
5
  import { addSsrMiddleware } from '../shared/addSsrMiddleware.js';
@@ -7,7 +7,7 @@ import pc from '@brillout/picocolors';
7
7
  import { logDockerHint } from './devConfig/index.js';
8
8
  function previewConfig() {
9
9
  let config;
10
- // let configVike: ConfigVikeResolved
10
+ // let vikeConfigGlobal: VikeConfigGlobal
11
11
  return {
12
12
  name: 'vike:previewConfig',
13
13
  apply: applyPreview,
@@ -22,18 +22,18 @@ function previewConfig() {
22
22
  async configResolved(config_) {
23
23
  config = config_;
24
24
  logDockerHint(config.preview.host);
25
- // configVike = await getConfigVike(config)
25
+ // const vikeConfig = await getVikeConfig(config)
26
+ // vikeConfigGlobal = vikeConfig.vikeConfigGlobal
26
27
  },
27
28
  configurePreviewServer(server) {
28
29
  /* - Couldn't make `appType: 'mpa'` work as of npm:@brillout/vite@5.0.0-beta.14.0426910c
29
30
  - This ugly hack to set appType for preview won't be need once https://github.com/vitejs/vite/pull/14855 is merged.
30
31
  config.appType = 'mpa'
31
32
  */
32
- markEnvAsVitePreview();
33
33
  return () => {
34
34
  assertDist();
35
35
  /* We don't use this condition (we wrongfully always use the SSR middleware) because of the regression introduced by https://github.com/vitejs/vite/pull/14756 which stops servering .html files when `appType: 'custom'`.
36
- if (!configVike.prerender || configVike.prerender.partial) {
36
+ if (!vikeConfigGlobal.prerender || vikeConfigGlobal.prerender.partial) {
37
37
  addSsrMiddleware(server.middlewares, config, true)
38
38
  }
39
39
  /*/
@@ -1,3 +1,3 @@
1
1
  export { setGlobalContext };
2
2
  import type { Plugin } from 'vite';
3
- declare function setGlobalContext(): Plugin;
3
+ declare function setGlobalContext(): Plugin[];