@sveltejs/kit 1.0.0-next.351 → 1.0.0-next.354
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.
- package/assets/app/env.js +13 -1
- package/dist/chunks/error.js +673 -0
- package/dist/chunks/index.js +15519 -1138
- package/dist/chunks/index2.js +177 -101
- package/dist/chunks/sync.js +180 -9
- package/dist/chunks/write_tsconfig.js +108 -3
- package/dist/cli.js +45 -830
- package/dist/vite.js +3009 -0
- package/package.json +4 -1
- package/types/ambient.d.ts +19 -6
- package/dist/chunks/constants.js +0 -663
- package/dist/chunks/filesystem.js +0 -110
- package/dist/chunks/index3.js +0 -183
- package/dist/chunks/index4.js +0 -215
- package/dist/chunks/index5.js +0 -15748
- package/dist/chunks/misc.js +0 -78
- package/dist/chunks/object.js +0 -83
- package/dist/chunks/plugin.js +0 -555
package/dist/cli.js
CHANGED
|
@@ -1,781 +1,11 @@
|
|
|
1
1
|
import chokidar from 'chokidar';
|
|
2
2
|
import fs__default from 'fs';
|
|
3
|
-
import path__default
|
|
3
|
+
import path__default from 'path';
|
|
4
|
+
import { l as load_config, $, c as coalesce_to_error } from './chunks/error.js';
|
|
4
5
|
import sade from 'sade';
|
|
5
6
|
import * as vite from 'vite';
|
|
6
|
-
import * as url from 'url';
|
|
7
7
|
import { networkInterfaces, release } from 'os';
|
|
8
|
-
|
|
9
|
-
let FORCE_COLOR, NODE_DISABLE_COLORS, NO_COLOR, TERM, isTTY=true;
|
|
10
|
-
if (typeof process !== 'undefined') {
|
|
11
|
-
({ FORCE_COLOR, NODE_DISABLE_COLORS, NO_COLOR, TERM } = process.env);
|
|
12
|
-
isTTY = process.stdout && process.stdout.isTTY;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const $ = {
|
|
16
|
-
enabled: !NODE_DISABLE_COLORS && NO_COLOR == null && TERM !== 'dumb' && (
|
|
17
|
-
FORCE_COLOR != null && FORCE_COLOR !== '0' || isTTY
|
|
18
|
-
),
|
|
19
|
-
|
|
20
|
-
// modifiers
|
|
21
|
-
reset: init(0, 0),
|
|
22
|
-
bold: init(1, 22),
|
|
23
|
-
dim: init(2, 22),
|
|
24
|
-
italic: init(3, 23),
|
|
25
|
-
underline: init(4, 24),
|
|
26
|
-
inverse: init(7, 27),
|
|
27
|
-
hidden: init(8, 28),
|
|
28
|
-
strikethrough: init(9, 29),
|
|
29
|
-
|
|
30
|
-
// colors
|
|
31
|
-
black: init(30, 39),
|
|
32
|
-
red: init(31, 39),
|
|
33
|
-
green: init(32, 39),
|
|
34
|
-
yellow: init(33, 39),
|
|
35
|
-
blue: init(34, 39),
|
|
36
|
-
magenta: init(35, 39),
|
|
37
|
-
cyan: init(36, 39),
|
|
38
|
-
white: init(37, 39),
|
|
39
|
-
gray: init(90, 39),
|
|
40
|
-
grey: init(90, 39),
|
|
41
|
-
|
|
42
|
-
// background colors
|
|
43
|
-
bgBlack: init(40, 49),
|
|
44
|
-
bgRed: init(41, 49),
|
|
45
|
-
bgGreen: init(42, 49),
|
|
46
|
-
bgYellow: init(43, 49),
|
|
47
|
-
bgBlue: init(44, 49),
|
|
48
|
-
bgMagenta: init(45, 49),
|
|
49
|
-
bgCyan: init(46, 49),
|
|
50
|
-
bgWhite: init(47, 49)
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
function run(arr, str) {
|
|
54
|
-
let i=0, tmp, beg='', end='';
|
|
55
|
-
for (; i < arr.length; i++) {
|
|
56
|
-
tmp = arr[i];
|
|
57
|
-
beg += tmp.open;
|
|
58
|
-
end += tmp.close;
|
|
59
|
-
if (!!~str.indexOf(tmp.close)) {
|
|
60
|
-
str = str.replace(tmp.rgx, tmp.close + tmp.open);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
return beg + str + end;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
function chain(has, keys) {
|
|
67
|
-
let ctx = { has, keys };
|
|
68
|
-
|
|
69
|
-
ctx.reset = $.reset.bind(ctx);
|
|
70
|
-
ctx.bold = $.bold.bind(ctx);
|
|
71
|
-
ctx.dim = $.dim.bind(ctx);
|
|
72
|
-
ctx.italic = $.italic.bind(ctx);
|
|
73
|
-
ctx.underline = $.underline.bind(ctx);
|
|
74
|
-
ctx.inverse = $.inverse.bind(ctx);
|
|
75
|
-
ctx.hidden = $.hidden.bind(ctx);
|
|
76
|
-
ctx.strikethrough = $.strikethrough.bind(ctx);
|
|
77
|
-
|
|
78
|
-
ctx.black = $.black.bind(ctx);
|
|
79
|
-
ctx.red = $.red.bind(ctx);
|
|
80
|
-
ctx.green = $.green.bind(ctx);
|
|
81
|
-
ctx.yellow = $.yellow.bind(ctx);
|
|
82
|
-
ctx.blue = $.blue.bind(ctx);
|
|
83
|
-
ctx.magenta = $.magenta.bind(ctx);
|
|
84
|
-
ctx.cyan = $.cyan.bind(ctx);
|
|
85
|
-
ctx.white = $.white.bind(ctx);
|
|
86
|
-
ctx.gray = $.gray.bind(ctx);
|
|
87
|
-
ctx.grey = $.grey.bind(ctx);
|
|
88
|
-
|
|
89
|
-
ctx.bgBlack = $.bgBlack.bind(ctx);
|
|
90
|
-
ctx.bgRed = $.bgRed.bind(ctx);
|
|
91
|
-
ctx.bgGreen = $.bgGreen.bind(ctx);
|
|
92
|
-
ctx.bgYellow = $.bgYellow.bind(ctx);
|
|
93
|
-
ctx.bgBlue = $.bgBlue.bind(ctx);
|
|
94
|
-
ctx.bgMagenta = $.bgMagenta.bind(ctx);
|
|
95
|
-
ctx.bgCyan = $.bgCyan.bind(ctx);
|
|
96
|
-
ctx.bgWhite = $.bgWhite.bind(ctx);
|
|
97
|
-
|
|
98
|
-
return ctx;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
function init(open, close) {
|
|
102
|
-
let blk = {
|
|
103
|
-
open: `\x1b[${open}m`,
|
|
104
|
-
close: `\x1b[${close}m`,
|
|
105
|
-
rgx: new RegExp(`\\x1b\\[${close}m`, 'g')
|
|
106
|
-
};
|
|
107
|
-
return function (txt) {
|
|
108
|
-
if (this !== void 0 && this.has !== void 0) {
|
|
109
|
-
!!~this.has.indexOf(open) || (this.has.push(open),this.keys.push(blk));
|
|
110
|
-
return txt === void 0 ? this : $.enabled ? run(this.keys, txt+'') : txt+'';
|
|
111
|
-
}
|
|
112
|
-
return txt === void 0 ? chain([open], [blk]) : $.enabled ? run([blk], txt+'') : txt+'';
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
const get_runtime_path = /** @param {import('types').ValidatedKitConfig} config */ (config) =>
|
|
117
|
-
posixify_path(path__default.join(config.outDir, 'runtime'))
|
|
118
|
-
;
|
|
119
|
-
|
|
120
|
-
/** @param {string} str */
|
|
121
|
-
function posixify_path(str) {
|
|
122
|
-
const parsed = path__default.parse(str);
|
|
123
|
-
return `/${parsed.dir.slice(parsed.root.length).split(path__default.sep).join('/')}/${parsed.base}`;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
function noop() {}
|
|
127
|
-
|
|
128
|
-
/** @param {{ verbose: boolean }} opts */
|
|
129
|
-
function logger({ verbose }) {
|
|
130
|
-
/** @type {import('types').Logger} */
|
|
131
|
-
const log = (msg) => console.log(msg.replace(/^/gm, ' '));
|
|
132
|
-
|
|
133
|
-
/** @param {string} msg */
|
|
134
|
-
const err = (msg) => console.error(msg.replace(/^/gm, ' '));
|
|
135
|
-
|
|
136
|
-
log.success = (msg) => log($.green(`✔ ${msg}`));
|
|
137
|
-
log.error = (msg) => err($.bold().red(msg));
|
|
138
|
-
log.warn = (msg) => log($.bold().yellow(msg));
|
|
139
|
-
|
|
140
|
-
log.minor = verbose ? (msg) => log($.grey(msg)) : noop;
|
|
141
|
-
log.info = verbose ? log : noop;
|
|
142
|
-
|
|
143
|
-
return log;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* Given an entry point like [cwd]/src/hooks, returns a filename like [cwd]/src/hooks.js or [cwd]/src/hooks/index.js
|
|
148
|
-
* @param {string} entry
|
|
149
|
-
* @returns {string|null}
|
|
150
|
-
*/
|
|
151
|
-
function resolve_entry(entry) {
|
|
152
|
-
if (fs__default.existsSync(entry)) {
|
|
153
|
-
const stats = fs__default.statSync(entry);
|
|
154
|
-
if (stats.isDirectory()) {
|
|
155
|
-
return resolve_entry(path__default.join(entry, 'index'));
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
return entry;
|
|
159
|
-
} else {
|
|
160
|
-
const dir = path__default.dirname(entry);
|
|
161
|
-
|
|
162
|
-
if (fs__default.existsSync(dir)) {
|
|
163
|
-
const base = path__default.basename(entry);
|
|
164
|
-
const files = fs__default.readdirSync(dir);
|
|
165
|
-
|
|
166
|
-
const found = files.find((file) => file.replace(/\.[^.]+$/, '') === base);
|
|
167
|
-
|
|
168
|
-
if (found) return path__default.join(dir, found);
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
return null;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
/** @param {import('types').ManifestData} manifest_data */
|
|
176
|
-
function get_mime_lookup(manifest_data) {
|
|
177
|
-
/** @type {Record<string, string>} */
|
|
178
|
-
const mime = {};
|
|
179
|
-
|
|
180
|
-
manifest_data.assets.forEach((asset) => {
|
|
181
|
-
if (asset.type) {
|
|
182
|
-
const ext = path__default.extname(asset.file);
|
|
183
|
-
mime[ext] = asset.type;
|
|
184
|
-
}
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
return mime;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
/** @param {import('types').ValidatedKitConfig} config */
|
|
191
|
-
function get_aliases(config) {
|
|
192
|
-
/** @type {Record<string, string>} */
|
|
193
|
-
const alias = {
|
|
194
|
-
__GENERATED__: path__default.posix.join(config.outDir, 'generated'),
|
|
195
|
-
$app: `${get_runtime_path(config)}/app`,
|
|
196
|
-
|
|
197
|
-
// For now, we handle `$lib` specially here rather than make it a default value for
|
|
198
|
-
// `config.kit.alias` since it has special meaning for packaging, etc.
|
|
199
|
-
$lib: config.files.lib
|
|
200
|
-
};
|
|
201
|
-
|
|
202
|
-
for (const [key, value] of Object.entries(config.alias)) {
|
|
203
|
-
alias[key] = path__default.resolve(value);
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
return alias;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
/** @typedef {import('./types').Validator} Validator */
|
|
210
|
-
|
|
211
|
-
/** @type {Validator} */
|
|
212
|
-
const options = object(
|
|
213
|
-
{
|
|
214
|
-
extensions: validate(['.svelte'], (input, keypath) => {
|
|
215
|
-
if (!Array.isArray(input) || !input.every((page) => typeof page === 'string')) {
|
|
216
|
-
throw new Error(`${keypath} must be an array of strings`);
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
input.forEach((extension) => {
|
|
220
|
-
if (extension[0] !== '.') {
|
|
221
|
-
throw new Error(`Each member of ${keypath} must start with '.' — saw '${extension}'`);
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
if (!/^(\.[a-z0-9]+)+$/i.test(extension)) {
|
|
225
|
-
throw new Error(`File extensions must be alphanumeric — saw '${extension}'`);
|
|
226
|
-
}
|
|
227
|
-
});
|
|
228
|
-
|
|
229
|
-
return input;
|
|
230
|
-
}),
|
|
231
|
-
|
|
232
|
-
kit: object({
|
|
233
|
-
adapter: validate(null, (input, keypath) => {
|
|
234
|
-
if (typeof input !== 'object' || !input.adapt) {
|
|
235
|
-
let message = `${keypath} should be an object with an "adapt" method`;
|
|
236
|
-
|
|
237
|
-
if (Array.isArray(input) || typeof input === 'string') {
|
|
238
|
-
// for the early adapter adopters
|
|
239
|
-
message += ', rather than the name of an adapter';
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
throw new Error(`${message}. See https://kit.svelte.dev/docs/adapters`);
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
return input;
|
|
246
|
-
}),
|
|
247
|
-
|
|
248
|
-
alias: validate({}, (input, keypath) => {
|
|
249
|
-
if (typeof input !== 'object') {
|
|
250
|
-
throw new Error(`${keypath} should be an object`);
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
for (const key in input) {
|
|
254
|
-
assert_string(input[key], `${keypath}.${key}`);
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
return input;
|
|
258
|
-
}),
|
|
259
|
-
|
|
260
|
-
// TODO: remove this for the 1.0 release
|
|
261
|
-
amp: error(
|
|
262
|
-
(keypath) =>
|
|
263
|
-
`${keypath} has been removed. See https://kit.svelte.dev/docs/seo#amp for details on how to support AMP`
|
|
264
|
-
),
|
|
265
|
-
|
|
266
|
-
appDir: validate('_app', (input, keypath) => {
|
|
267
|
-
assert_string(input, keypath);
|
|
268
|
-
|
|
269
|
-
if (input) {
|
|
270
|
-
if (input.startsWith('/') || input.endsWith('/')) {
|
|
271
|
-
throw new Error(
|
|
272
|
-
"config.kit.appDir cannot start or end with '/'. See https://kit.svelte.dev/docs/configuration"
|
|
273
|
-
);
|
|
274
|
-
}
|
|
275
|
-
} else {
|
|
276
|
-
throw new Error(`${keypath} cannot be empty`);
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
return input;
|
|
280
|
-
}),
|
|
281
|
-
|
|
282
|
-
browser: object({
|
|
283
|
-
hydrate: boolean(true),
|
|
284
|
-
router: boolean(true)
|
|
285
|
-
}),
|
|
286
|
-
|
|
287
|
-
csp: object({
|
|
288
|
-
mode: list(['auto', 'hash', 'nonce']),
|
|
289
|
-
directives: object({
|
|
290
|
-
'child-src': string_array(),
|
|
291
|
-
'default-src': string_array(),
|
|
292
|
-
'frame-src': string_array(),
|
|
293
|
-
'worker-src': string_array(),
|
|
294
|
-
'connect-src': string_array(),
|
|
295
|
-
'font-src': string_array(),
|
|
296
|
-
'img-src': string_array(),
|
|
297
|
-
'manifest-src': string_array(),
|
|
298
|
-
'media-src': string_array(),
|
|
299
|
-
'object-src': string_array(),
|
|
300
|
-
'prefetch-src': string_array(),
|
|
301
|
-
'script-src': string_array(),
|
|
302
|
-
'script-src-elem': string_array(),
|
|
303
|
-
'script-src-attr': string_array(),
|
|
304
|
-
'style-src': string_array(),
|
|
305
|
-
'style-src-elem': string_array(),
|
|
306
|
-
'style-src-attr': string_array(),
|
|
307
|
-
'base-uri': string_array(),
|
|
308
|
-
sandbox: string_array(),
|
|
309
|
-
'form-action': string_array(),
|
|
310
|
-
'frame-ancestors': string_array(),
|
|
311
|
-
'navigate-to': string_array(),
|
|
312
|
-
'report-uri': string_array(),
|
|
313
|
-
'report-to': string_array(),
|
|
314
|
-
'require-trusted-types-for': string_array(),
|
|
315
|
-
'trusted-types': string_array(),
|
|
316
|
-
'upgrade-insecure-requests': boolean(false),
|
|
317
|
-
'require-sri-for': string_array(),
|
|
318
|
-
'block-all-mixed-content': boolean(false),
|
|
319
|
-
'plugin-types': string_array(),
|
|
320
|
-
referrer: string_array()
|
|
321
|
-
})
|
|
322
|
-
}),
|
|
323
|
-
|
|
324
|
-
endpointExtensions: string_array(['.js', '.ts']),
|
|
325
|
-
|
|
326
|
-
files: object({
|
|
327
|
-
assets: string('static'),
|
|
328
|
-
hooks: string(join('src', 'hooks')),
|
|
329
|
-
lib: string(join('src', 'lib')),
|
|
330
|
-
params: string(join('src', 'params')),
|
|
331
|
-
routes: string(join('src', 'routes')),
|
|
332
|
-
serviceWorker: string(join('src', 'service-worker')),
|
|
333
|
-
template: string(join('src', 'app.html'))
|
|
334
|
-
}),
|
|
335
|
-
|
|
336
|
-
floc: boolean(false),
|
|
337
|
-
|
|
338
|
-
// TODO: remove this for the 1.0 release
|
|
339
|
-
headers: error(
|
|
340
|
-
(keypath) =>
|
|
341
|
-
`${keypath} has been removed. See https://github.com/sveltejs/kit/pull/3384 for details`
|
|
342
|
-
),
|
|
343
|
-
|
|
344
|
-
// TODO: remove this for the 1.0 release
|
|
345
|
-
host: error(
|
|
346
|
-
(keypath) =>
|
|
347
|
-
`${keypath} has been removed. See https://github.com/sveltejs/kit/pull/3384 for details`
|
|
348
|
-
),
|
|
349
|
-
|
|
350
|
-
// TODO remove for 1.0
|
|
351
|
-
hydrate: error((keypath) => `${keypath} has been moved to config.kit.browser.hydrate`),
|
|
352
|
-
|
|
353
|
-
inlineStyleThreshold: number(0),
|
|
354
|
-
|
|
355
|
-
methodOverride: object({
|
|
356
|
-
parameter: string('_method'),
|
|
357
|
-
allowed: validate([], (input, keypath) => {
|
|
358
|
-
if (!Array.isArray(input) || !input.every((method) => typeof method === 'string')) {
|
|
359
|
-
throw new Error(`${keypath} must be an array of strings`);
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
if (input.map((i) => i.toUpperCase()).includes('GET')) {
|
|
363
|
-
throw new Error(`${keypath} cannot contain "GET"`);
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
return input;
|
|
367
|
-
})
|
|
368
|
-
}),
|
|
369
|
-
|
|
370
|
-
outDir: string('.svelte-kit'),
|
|
371
|
-
|
|
372
|
-
package: object({
|
|
373
|
-
dir: string('package'),
|
|
374
|
-
// excludes all .d.ts and filename starting with _
|
|
375
|
-
exports: fun((filepath) => !/^_|\/_|\.d\.ts$/.test(filepath)),
|
|
376
|
-
files: fun(() => true),
|
|
377
|
-
emitTypes: boolean(true)
|
|
378
|
-
}),
|
|
379
|
-
|
|
380
|
-
paths: object({
|
|
381
|
-
base: validate('', (input, keypath) => {
|
|
382
|
-
assert_string(input, keypath);
|
|
383
|
-
|
|
384
|
-
if (input !== '' && (input.endsWith('/') || !input.startsWith('/'))) {
|
|
385
|
-
throw new Error(
|
|
386
|
-
`${keypath} option must either be the empty string or a root-relative path that starts but doesn't end with '/'. See https://kit.svelte.dev/docs/configuration#paths`
|
|
387
|
-
);
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
return input;
|
|
391
|
-
}),
|
|
392
|
-
assets: validate('', (input, keypath) => {
|
|
393
|
-
assert_string(input, keypath);
|
|
394
|
-
|
|
395
|
-
if (input) {
|
|
396
|
-
if (!/^[a-z]+:\/\//.test(input)) {
|
|
397
|
-
throw new Error(
|
|
398
|
-
`${keypath} option must be an absolute path, if specified. See https://kit.svelte.dev/docs/configuration#paths`
|
|
399
|
-
);
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
if (input.endsWith('/')) {
|
|
403
|
-
throw new Error(
|
|
404
|
-
`${keypath} option must not end with '/'. See https://kit.svelte.dev/docs/configuration#paths`
|
|
405
|
-
);
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
return input;
|
|
410
|
-
})
|
|
411
|
-
}),
|
|
412
|
-
|
|
413
|
-
prerender: object({
|
|
414
|
-
concurrency: number(1),
|
|
415
|
-
crawl: boolean(true),
|
|
416
|
-
createIndexFiles: error(
|
|
417
|
-
(keypath) =>
|
|
418
|
-
`${keypath} has been removed — it is now controlled by the trailingSlash option. See https://kit.svelte.dev/docs/configuration#trailingslash`
|
|
419
|
-
),
|
|
420
|
-
default: boolean(false),
|
|
421
|
-
enabled: boolean(true),
|
|
422
|
-
entries: validate(['*'], (input, keypath) => {
|
|
423
|
-
if (!Array.isArray(input) || !input.every((page) => typeof page === 'string')) {
|
|
424
|
-
throw new Error(`${keypath} must be an array of strings`);
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
input.forEach((page) => {
|
|
428
|
-
if (page !== '*' && page[0] !== '/') {
|
|
429
|
-
throw new Error(
|
|
430
|
-
`Each member of ${keypath} must be either '*' or an absolute path beginning with '/' — saw '${page}'`
|
|
431
|
-
);
|
|
432
|
-
}
|
|
433
|
-
});
|
|
434
|
-
|
|
435
|
-
return input;
|
|
436
|
-
}),
|
|
437
|
-
|
|
438
|
-
// TODO: remove this for the 1.0 release
|
|
439
|
-
force: validate(undefined, (input, keypath) => {
|
|
440
|
-
if (typeof input !== 'undefined') {
|
|
441
|
-
const newSetting = input ? 'continue' : 'fail';
|
|
442
|
-
const needsSetting = newSetting === 'continue';
|
|
443
|
-
throw new Error(
|
|
444
|
-
`${keypath} has been removed in favor of \`onError\`. In your case, set \`onError\` to "${newSetting}"${
|
|
445
|
-
needsSetting ? '' : ' (or leave it undefined)'
|
|
446
|
-
} to get the same behavior as you would with \`force: ${JSON.stringify(input)}\``
|
|
447
|
-
);
|
|
448
|
-
}
|
|
449
|
-
}),
|
|
450
|
-
|
|
451
|
-
onError: validate('fail', (input, keypath) => {
|
|
452
|
-
if (typeof input === 'function') return input;
|
|
453
|
-
if (['continue', 'fail'].includes(input)) return input;
|
|
454
|
-
throw new Error(
|
|
455
|
-
`${keypath} should be either a custom function or one of "continue" or "fail"`
|
|
456
|
-
);
|
|
457
|
-
}),
|
|
458
|
-
|
|
459
|
-
// TODO: remove this for the 1.0 release
|
|
460
|
-
pages: error((keypath) => `${keypath} has been renamed to \`entries\`.`)
|
|
461
|
-
}),
|
|
462
|
-
|
|
463
|
-
// TODO: remove this for the 1.0 release
|
|
464
|
-
protocol: error(
|
|
465
|
-
(keypath) =>
|
|
466
|
-
`${keypath} has been removed. See https://github.com/sveltejs/kit/pull/3384 for details`
|
|
467
|
-
),
|
|
468
|
-
|
|
469
|
-
// TODO remove for 1.0
|
|
470
|
-
router: error((keypath) => `${keypath} has been moved to config.kit.browser.router`),
|
|
471
|
-
|
|
472
|
-
routes: fun((filepath) => !/(?:(?:^_|\/_)|(?:^\.|\/\.)(?!well-known))/.test(filepath)),
|
|
473
|
-
|
|
474
|
-
serviceWorker: object({
|
|
475
|
-
register: boolean(true),
|
|
476
|
-
files: fun((filename) => !/\.DS_Store/.test(filename))
|
|
477
|
-
}),
|
|
478
|
-
|
|
479
|
-
// TODO remove this for 1.0
|
|
480
|
-
ssr: error(
|
|
481
|
-
(keypath) =>
|
|
482
|
-
`${keypath} has been removed — use the handle hook instead: https://kit.svelte.dev/docs/hooks#handle'`
|
|
483
|
-
),
|
|
484
|
-
|
|
485
|
-
// TODO remove this for 1.0
|
|
486
|
-
target: error((keypath) => `${keypath} is no longer required, and should be removed`),
|
|
487
|
-
|
|
488
|
-
trailingSlash: list(['never', 'always', 'ignore']),
|
|
489
|
-
|
|
490
|
-
version: object({
|
|
491
|
-
name: string(Date.now().toString()),
|
|
492
|
-
pollInterval: number(0)
|
|
493
|
-
}),
|
|
494
|
-
|
|
495
|
-
vite: validate(
|
|
496
|
-
() => ({}),
|
|
497
|
-
(input, keypath) => {
|
|
498
|
-
if (typeof input === 'object') {
|
|
499
|
-
const config = input;
|
|
500
|
-
input = () => config;
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
if (typeof input !== 'function') {
|
|
504
|
-
throw new Error(
|
|
505
|
-
`${keypath} must be a Vite config object (https://vitejs.dev/config) or a function that returns one`
|
|
506
|
-
);
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
return input;
|
|
510
|
-
}
|
|
511
|
-
)
|
|
512
|
-
})
|
|
513
|
-
},
|
|
514
|
-
true
|
|
515
|
-
);
|
|
516
|
-
|
|
517
|
-
/**
|
|
518
|
-
* @param {Record<string, Validator>} children
|
|
519
|
-
* @param {boolean} [allow_unknown]
|
|
520
|
-
* @returns {Validator}
|
|
521
|
-
*/
|
|
522
|
-
function object(children, allow_unknown) {
|
|
523
|
-
return (input, keypath) => {
|
|
524
|
-
/** @type {Record<string, any>} */
|
|
525
|
-
const output = {};
|
|
526
|
-
|
|
527
|
-
if ((input && typeof input !== 'object') || Array.isArray(input)) {
|
|
528
|
-
throw new Error(`${keypath} should be an object`);
|
|
529
|
-
}
|
|
530
|
-
|
|
531
|
-
for (const key in input) {
|
|
532
|
-
if (!(key in children)) {
|
|
533
|
-
if (allow_unknown) {
|
|
534
|
-
output[key] = input[key];
|
|
535
|
-
} else {
|
|
536
|
-
let message = `Unexpected option ${keypath}.${key}`;
|
|
537
|
-
|
|
538
|
-
// special case
|
|
539
|
-
if (keypath === 'config.kit' && key in options) {
|
|
540
|
-
message += ` (did you mean config.${key}?)`;
|
|
541
|
-
}
|
|
542
|
-
|
|
543
|
-
throw new Error(message);
|
|
544
|
-
}
|
|
545
|
-
}
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
for (const key in children) {
|
|
549
|
-
const validator = children[key];
|
|
550
|
-
output[key] = validator(input && input[key], `${keypath}.${key}`);
|
|
551
|
-
}
|
|
552
|
-
|
|
553
|
-
return output;
|
|
554
|
-
};
|
|
555
|
-
}
|
|
556
|
-
|
|
557
|
-
/**
|
|
558
|
-
* @param {any} fallback
|
|
559
|
-
* @param {(value: any, keypath: string) => any} fn
|
|
560
|
-
* @returns {Validator}
|
|
561
|
-
*/
|
|
562
|
-
function validate(fallback, fn) {
|
|
563
|
-
return (input, keypath) => {
|
|
564
|
-
return input === undefined ? fallback : fn(input, keypath);
|
|
565
|
-
};
|
|
566
|
-
}
|
|
567
|
-
|
|
568
|
-
/**
|
|
569
|
-
* @param {string | null} fallback
|
|
570
|
-
* @param {boolean} allow_empty
|
|
571
|
-
* @returns {Validator}
|
|
572
|
-
*/
|
|
573
|
-
function string(fallback, allow_empty = true) {
|
|
574
|
-
return validate(fallback, (input, keypath) => {
|
|
575
|
-
assert_string(input, keypath);
|
|
576
|
-
|
|
577
|
-
if (!allow_empty && input === '') {
|
|
578
|
-
throw new Error(`${keypath} cannot be empty`);
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
return input;
|
|
582
|
-
});
|
|
583
|
-
}
|
|
584
|
-
|
|
585
|
-
/**
|
|
586
|
-
* @param {string[] | undefined} [fallback]
|
|
587
|
-
* @returns {Validator}
|
|
588
|
-
*/
|
|
589
|
-
function string_array(fallback) {
|
|
590
|
-
return validate(fallback, (input, keypath) => {
|
|
591
|
-
if (input === undefined) return input;
|
|
592
|
-
|
|
593
|
-
if (!Array.isArray(input) || input.some((value) => typeof value !== 'string')) {
|
|
594
|
-
throw new Error(`${keypath} must be an array of strings, if specified`);
|
|
595
|
-
}
|
|
596
|
-
|
|
597
|
-
return input;
|
|
598
|
-
});
|
|
599
|
-
}
|
|
600
|
-
|
|
601
|
-
/**
|
|
602
|
-
* @param {number} fallback
|
|
603
|
-
* @returns {Validator}
|
|
604
|
-
*/
|
|
605
|
-
function number(fallback) {
|
|
606
|
-
return validate(fallback, (input, keypath) => {
|
|
607
|
-
if (typeof input !== 'number') {
|
|
608
|
-
throw new Error(`${keypath} should be a number, if specified`);
|
|
609
|
-
}
|
|
610
|
-
return input;
|
|
611
|
-
});
|
|
612
|
-
}
|
|
613
|
-
|
|
614
|
-
/**
|
|
615
|
-
* @param {boolean} fallback
|
|
616
|
-
* @returns {Validator}
|
|
617
|
-
*/
|
|
618
|
-
function boolean(fallback) {
|
|
619
|
-
return validate(fallback, (input, keypath) => {
|
|
620
|
-
if (typeof input !== 'boolean') {
|
|
621
|
-
throw new Error(`${keypath} should be true or false, if specified`);
|
|
622
|
-
}
|
|
623
|
-
return input;
|
|
624
|
-
});
|
|
625
|
-
}
|
|
626
|
-
|
|
627
|
-
/**
|
|
628
|
-
* @param {string[]} options
|
|
629
|
-
* @returns {Validator}
|
|
630
|
-
*/
|
|
631
|
-
function list(options, fallback = options[0]) {
|
|
632
|
-
return validate(fallback, (input, keypath) => {
|
|
633
|
-
if (!options.includes(input)) {
|
|
634
|
-
// prettier-ignore
|
|
635
|
-
const msg = options.length > 2
|
|
636
|
-
? `${keypath} should be one of ${options.slice(0, -1).map(input => `"${input}"`).join(', ')} or "${options[options.length - 1]}"`
|
|
637
|
-
: `${keypath} should be either "${options[0]}" or "${options[1]}"`;
|
|
638
|
-
|
|
639
|
-
throw new Error(msg);
|
|
640
|
-
}
|
|
641
|
-
return input;
|
|
642
|
-
});
|
|
643
|
-
}
|
|
644
|
-
|
|
645
|
-
/**
|
|
646
|
-
* @param {(filename: string) => boolean} fallback
|
|
647
|
-
* @returns {Validator}
|
|
648
|
-
*/
|
|
649
|
-
function fun(fallback) {
|
|
650
|
-
return validate(fallback, (input, keypath) => {
|
|
651
|
-
if (typeof input !== 'function') {
|
|
652
|
-
throw new Error(`${keypath} should be a function, if specified`);
|
|
653
|
-
}
|
|
654
|
-
return input;
|
|
655
|
-
});
|
|
656
|
-
}
|
|
657
|
-
|
|
658
|
-
/**
|
|
659
|
-
* @param {string} input
|
|
660
|
-
* @param {string} keypath
|
|
661
|
-
*/
|
|
662
|
-
function assert_string(input, keypath) {
|
|
663
|
-
if (typeof input !== 'string') {
|
|
664
|
-
throw new Error(`${keypath} should be a string, if specified`);
|
|
665
|
-
}
|
|
666
|
-
}
|
|
667
|
-
|
|
668
|
-
/** @param {(keypath?: string) => string} fn */
|
|
669
|
-
function error(fn) {
|
|
670
|
-
return validate(undefined, (input, keypath) => {
|
|
671
|
-
if (input !== undefined) {
|
|
672
|
-
throw new Error(fn(keypath));
|
|
673
|
-
}
|
|
674
|
-
});
|
|
675
|
-
}
|
|
676
|
-
|
|
677
|
-
/**
|
|
678
|
-
* Loads the template (src/app.html by default) and validates that it has the
|
|
679
|
-
* required content.
|
|
680
|
-
* @param {string} cwd
|
|
681
|
-
* @param {import('types').ValidatedConfig} config
|
|
682
|
-
*/
|
|
683
|
-
function load_template(cwd, config) {
|
|
684
|
-
const { template } = config.kit.files;
|
|
685
|
-
const relative = path__default.relative(cwd, template);
|
|
686
|
-
|
|
687
|
-
if (fs__default.existsSync(template)) {
|
|
688
|
-
const contents = fs__default.readFileSync(template, 'utf8');
|
|
689
|
-
|
|
690
|
-
// TODO remove this for 1.0
|
|
691
|
-
const match = /%svelte\.([a-z]+)%/.exec(contents);
|
|
692
|
-
if (match) {
|
|
693
|
-
throw new Error(
|
|
694
|
-
`%svelte.${match[1]}% in ${relative} should be replaced with %sveltekit.${match[1]}%`
|
|
695
|
-
);
|
|
696
|
-
}
|
|
697
|
-
|
|
698
|
-
const expected_tags = ['%sveltekit.head%', '%sveltekit.body%'];
|
|
699
|
-
expected_tags.forEach((tag) => {
|
|
700
|
-
if (contents.indexOf(tag) === -1) {
|
|
701
|
-
throw new Error(`${relative} is missing ${tag}`);
|
|
702
|
-
}
|
|
703
|
-
});
|
|
704
|
-
} else {
|
|
705
|
-
throw new Error(`${relative} does not exist`);
|
|
706
|
-
}
|
|
707
|
-
|
|
708
|
-
return fs__default.readFileSync(template, 'utf-8');
|
|
709
|
-
}
|
|
710
|
-
|
|
711
|
-
/**
|
|
712
|
-
* Loads and validates svelte.config.js
|
|
713
|
-
* @param {{ cwd?: string }} options
|
|
714
|
-
* @returns {Promise<import('types').ValidatedConfig>}
|
|
715
|
-
*/
|
|
716
|
-
async function load_config({ cwd = process.cwd() } = {}) {
|
|
717
|
-
const config_file = path__default.join(cwd, 'svelte.config.js');
|
|
718
|
-
|
|
719
|
-
if (!fs__default.existsSync(config_file)) {
|
|
720
|
-
throw new Error(
|
|
721
|
-
'You need to create a svelte.config.js file. See https://kit.svelte.dev/docs/configuration'
|
|
722
|
-
);
|
|
723
|
-
}
|
|
724
|
-
|
|
725
|
-
const config = await import(`${url.pathToFileURL(config_file).href}?ts=${Date.now()}`);
|
|
726
|
-
|
|
727
|
-
const validated = validate_config(config.default);
|
|
728
|
-
|
|
729
|
-
validated.kit.outDir = path__default.resolve(cwd, validated.kit.outDir);
|
|
730
|
-
|
|
731
|
-
for (const key in validated.kit.files) {
|
|
732
|
-
// @ts-expect-error this is typescript at its stupidest
|
|
733
|
-
validated.kit.files[key] = path__default.resolve(cwd, validated.kit.files[key]);
|
|
734
|
-
}
|
|
735
|
-
|
|
736
|
-
return validated;
|
|
737
|
-
}
|
|
738
|
-
|
|
739
|
-
/**
|
|
740
|
-
* @param {import('types').Config} config
|
|
741
|
-
* @returns {import('types').ValidatedConfig}
|
|
742
|
-
*/
|
|
743
|
-
function validate_config(config) {
|
|
744
|
-
if (typeof config !== 'object') {
|
|
745
|
-
throw new Error(
|
|
746
|
-
'svelte.config.js must have a configuration object as its default export. See https://kit.svelte.dev/docs/configuration'
|
|
747
|
-
);
|
|
748
|
-
}
|
|
749
|
-
|
|
750
|
-
return options(config, 'config');
|
|
751
|
-
}
|
|
752
|
-
|
|
753
|
-
/**
|
|
754
|
-
* Ensures the user does not override any config values that SvelteKit must control.
|
|
755
|
-
* @param {string[]} conflicts - array of conflicts in dotted notation
|
|
756
|
-
* @param {string=} pathPrefix - prepended in front of the path
|
|
757
|
-
* @param {string=} scope - used to prefix the whole error message
|
|
758
|
-
*/
|
|
759
|
-
function print_config_conflicts(conflicts, pathPrefix, scope) {
|
|
760
|
-
const prefix = scope ? scope + ': ' : '';
|
|
761
|
-
const log = logger({ verbose: false });
|
|
762
|
-
conflicts.forEach((conflict) => {
|
|
763
|
-
log.error(
|
|
764
|
-
`${prefix}The value for ${pathPrefix}${conflict} specified in svelte.config.js has been ignored. This option is controlled by SvelteKit.`
|
|
765
|
-
);
|
|
766
|
-
});
|
|
767
|
-
}
|
|
768
|
-
|
|
769
|
-
/**
|
|
770
|
-
* @param {unknown} err
|
|
771
|
-
* @return {Error}
|
|
772
|
-
*/
|
|
773
|
-
function coalesce_to_error(err) {
|
|
774
|
-
return err instanceof Error ||
|
|
775
|
-
(err && /** @type {any} */ (err).name && /** @type {any} */ (err).message)
|
|
776
|
-
? /** @type {Error} */ (err)
|
|
777
|
-
: new Error(JSON.stringify(err));
|
|
778
|
-
}
|
|
8
|
+
import 'url';
|
|
779
9
|
|
|
780
10
|
/** @param {unknown} e */
|
|
781
11
|
function handle_error(e) {
|
|
@@ -811,7 +41,7 @@ async function launch(port, https, base) {
|
|
|
811
41
|
exec(`${cmd} ${https ? 'https' : 'http'}://localhost:${port}${base}`);
|
|
812
42
|
}
|
|
813
43
|
|
|
814
|
-
const prog = sade('svelte-kit').version('1.0.0-next.
|
|
44
|
+
const prog = sade('svelte-kit').version('1.0.0-next.354');
|
|
815
45
|
|
|
816
46
|
prog
|
|
817
47
|
.command('dev')
|
|
@@ -830,15 +60,8 @@ prog
|
|
|
830
60
|
let close;
|
|
831
61
|
|
|
832
62
|
async function start() {
|
|
833
|
-
const { plugins } = await import('./chunks/plugin.js');
|
|
834
63
|
const svelte_config = await load_config();
|
|
835
|
-
const
|
|
836
|
-
|
|
837
|
-
/** @type {import('vite').UserConfig} */
|
|
838
|
-
const config = {
|
|
839
|
-
...vite_config,
|
|
840
|
-
plugins: [...(vite_config.plugins || []), plugins(svelte_config)]
|
|
841
|
-
};
|
|
64
|
+
const config = await get_vite_config(svelte_config);
|
|
842
65
|
config.server = config.server || {};
|
|
843
66
|
|
|
844
67
|
// optional config from command-line flags
|
|
@@ -849,7 +72,7 @@ prog
|
|
|
849
72
|
|
|
850
73
|
// if https is already enabled then do nothing. it could be an object and we
|
|
851
74
|
// don't want to overwrite with a boolean
|
|
852
|
-
if (https && !
|
|
75
|
+
if (https && !config?.server?.https) {
|
|
853
76
|
config.server.https = https;
|
|
854
77
|
}
|
|
855
78
|
|
|
@@ -926,31 +149,11 @@ prog
|
|
|
926
149
|
.action(async ({ verbose }) => {
|
|
927
150
|
try {
|
|
928
151
|
process.env.NODE_ENV = process.env.NODE_ENV || 'production';
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
const log = logger({ verbose });
|
|
932
|
-
|
|
933
|
-
const { build } = await import('./chunks/index.js');
|
|
934
|
-
const { build_data, prerendered } = await build(config, { log });
|
|
152
|
+
process.env.VERBOSE = verbose;
|
|
935
153
|
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
);
|
|
939
|
-
|
|
940
|
-
if (config.kit.adapter) {
|
|
941
|
-
const { adapt } = await import('./chunks/index3.js');
|
|
942
|
-
await adapt(config, build_data, prerendered, { log });
|
|
943
|
-
|
|
944
|
-
// this is necessary to close any open db connections, etc
|
|
945
|
-
process.exit(0);
|
|
946
|
-
}
|
|
947
|
-
|
|
948
|
-
console.log($.bold().yellow('\nNo adapter specified'));
|
|
949
|
-
|
|
950
|
-
// prettier-ignore
|
|
951
|
-
console.log(
|
|
952
|
-
`See ${$.bold().cyan('https://kit.svelte.dev/docs/adapters')} to learn how to configure your app to run on the platform of your choosing`
|
|
953
|
-
);
|
|
154
|
+
const svelte_config = await load_config();
|
|
155
|
+
const vite_config = await get_vite_config(svelte_config);
|
|
156
|
+
await vite.build(vite_config); // TODO when we get rid of config.kit.vite, this can just be vite.build()
|
|
954
157
|
} catch (error) {
|
|
955
158
|
handle_error(error);
|
|
956
159
|
}
|
|
@@ -970,30 +173,18 @@ prog
|
|
|
970
173
|
|
|
971
174
|
process.env.NODE_ENV = process.env.NODE_ENV || 'production';
|
|
972
175
|
|
|
973
|
-
const { sveltekit_plugin } = await import('./chunks/index4.js');
|
|
974
176
|
const svelte_config = await load_config();
|
|
975
|
-
const vite_config = await svelte_config
|
|
177
|
+
const vite_config = await get_vite_config(svelte_config);
|
|
976
178
|
|
|
977
|
-
|
|
978
|
-
const config = {
|
|
979
|
-
...vite_config,
|
|
980
|
-
plugins: [...(vite_config.plugins || []), sveltekit_plugin]
|
|
981
|
-
};
|
|
982
|
-
config.preview = config.preview || {};
|
|
179
|
+
vite_config.preview = vite_config.preview || {};
|
|
983
180
|
|
|
984
181
|
// optional config from command-line flags
|
|
985
182
|
// these should take precedence, but not print conflict warnings
|
|
986
|
-
if (host)
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
if (https) {
|
|
990
|
-
config.preview.https = https;
|
|
991
|
-
}
|
|
992
|
-
if (port) {
|
|
993
|
-
config.preview.port = port;
|
|
994
|
-
}
|
|
183
|
+
if (host) vite_config.preview.host = host;
|
|
184
|
+
if (https) vite_config.preview.https = https;
|
|
185
|
+
if (port) vite_config.preview.port = port;
|
|
995
186
|
|
|
996
|
-
const preview_server = await vite.preview(
|
|
187
|
+
const preview_server = await vite.preview(vite_config);
|
|
997
188
|
|
|
998
189
|
welcome({ port, host, https, open, base: preview_server.config.base });
|
|
999
190
|
} catch (error) {
|
|
@@ -1008,7 +199,7 @@ prog
|
|
|
1008
199
|
.action(async ({ watch }) => {
|
|
1009
200
|
try {
|
|
1010
201
|
const config = await load_config();
|
|
1011
|
-
const packaging = await import('./chunks/
|
|
202
|
+
const packaging = await import('./chunks/index.js');
|
|
1012
203
|
|
|
1013
204
|
await (watch ? packaging.watch(config) : packaging.build(config));
|
|
1014
205
|
} catch (error) {
|
|
@@ -1027,7 +218,7 @@ prog
|
|
|
1027
218
|
|
|
1028
219
|
try {
|
|
1029
220
|
const config = await load_config();
|
|
1030
|
-
const sync = await import('./chunks/sync.js');
|
|
221
|
+
const sync = await import('./chunks/sync.js').then(function (n) { return n.d; });
|
|
1031
222
|
sync.all(config);
|
|
1032
223
|
} catch (error) {
|
|
1033
224
|
handle_error(error);
|
|
@@ -1051,7 +242,7 @@ prog.parse(process.argv, { unknown: (arg) => `Unknown option: ${arg}` });
|
|
|
1051
242
|
function welcome({ port, host, https, open, base, loose, allow, cwd }) {
|
|
1052
243
|
if (open) launch(port, https, base);
|
|
1053
244
|
|
|
1054
|
-
console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.
|
|
245
|
+
console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.354'}\n`));
|
|
1055
246
|
|
|
1056
247
|
const protocol = https ? 'https:' : 'http:';
|
|
1057
248
|
const exposed = typeof host !== 'undefined' && host !== 'localhost' && host !== '127.0.0.1';
|
|
@@ -1073,7 +264,7 @@ function welcome({ port, host, https, open, base, loose, allow, cwd }) {
|
|
|
1073
264
|
if (loose) {
|
|
1074
265
|
console.log(`\n ${$.yellow('Serving with vite.server.fs.strict: false. Note that all files on your machine will be accessible to anyone on your network.')}`);
|
|
1075
266
|
} else if (allow?.length && cwd) {
|
|
1076
|
-
console.log(`\n ${$.yellow('Note that all files in the following directories will be accessible to anyone on your network: ' + allow.map(a => relative(cwd, a)).join(', '))}`);
|
|
267
|
+
console.log(`\n ${$.yellow('Note that all files in the following directories will be accessible to anyone on your network: ' + allow.map(a => path__default.relative(cwd, a)).join(', '))}`);
|
|
1077
268
|
}
|
|
1078
269
|
} else {
|
|
1079
270
|
console.log(` ${$.gray('network: not exposed')}`);
|
|
@@ -1089,4 +280,28 @@ function welcome({ port, host, https, open, base, loose, allow, cwd }) {
|
|
|
1089
280
|
console.log('\n');
|
|
1090
281
|
}
|
|
1091
282
|
|
|
1092
|
-
|
|
283
|
+
/**
|
|
284
|
+
* @param {import('types').ValidatedConfig} svelte_config
|
|
285
|
+
* @return {Promise<import('vite').UserConfig>}
|
|
286
|
+
*/
|
|
287
|
+
async function get_vite_config(svelte_config) {
|
|
288
|
+
for (const file of ['vite.config.js', 'vite.config.mjs', 'vite.config.cjs']) {
|
|
289
|
+
if (fs__default.existsSync(file)) {
|
|
290
|
+
// TODO warn here if config.kit.vite was specified
|
|
291
|
+
const module = await import(path__default.resolve(file));
|
|
292
|
+
return {
|
|
293
|
+
...module.default,
|
|
294
|
+
configFile: false
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
const { sveltekit } = await import('./vite.js').then(function (n) { return n.i; });
|
|
300
|
+
|
|
301
|
+
// TODO: stop reading Vite config from SvelteKit config or move to CLI
|
|
302
|
+
const vite_config = await svelte_config.kit.vite();
|
|
303
|
+
vite_config.plugins = [...(vite_config.plugins || []), ...sveltekit()];
|
|
304
|
+
return vite_config;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
export { get_vite_config };
|