Skip to content

Commit

Permalink
[chore] provide Vite config via plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
benmccann committed May 25, 2022
1 parent 571831a commit 56af8d0
Show file tree
Hide file tree
Showing 5 changed files with 408 additions and 423 deletions.
5 changes: 5 additions & 0 deletions .changeset/cyan-files-hammer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

[chore] provide Vite config via plugin
34 changes: 24 additions & 10 deletions packages/kit/src/cli.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import sade from 'sade';
import colors from 'kleur';
import chokidar from 'chokidar';
import fs from 'fs';
import colors from 'kleur';
import { relative } from 'path';
import * as ports from 'port-authority';
import chokidar from 'chokidar';
import sade from 'sade';
import * as vite from 'vite';
import { load_config } from './core/config/index.js';
import { networkInterfaces, release } from 'os';
import { coalesce_to_error } from './utils/error.js';
Expand Down Expand Up @@ -62,13 +63,26 @@ prog
let close;

async function start() {
const { dev } = await import('./core/dev/index.js');
const { plugins } = await import('./core/dev/plugin.js');

const { server, config } = await dev({
port,
host,
https
});
/** @type {import('vite').UserConfig} */
const config = { plugins };
config.server = config.server || {};

// optional config from command-line flags
// these should take precedence, but not print conflict warnings
if (host) {
config.server.host = host;
}
if (https) {
config.server.https = https;
}
if (port) {
config.server.port = port;
}

const server = await vite.createServer(config);
await server.listen(port);

const address_info = /** @type {import('net').AddressInfo} */ (
/** @type {import('http').Server} */ (server.httpServer).address()
Expand All @@ -81,7 +95,7 @@ prog
host: address_info.address,
https: !!(https || vite_config.server.https),
open: first && (open || !!vite_config.server.open),
base: config.kit.paths.base,
base: svelte_config.kit.paths.base,
loose: vite_config.server.fs.strict === false,
allow: vite_config.server.fs.allow
});
Expand Down
104 changes: 0 additions & 104 deletions packages/kit/src/core/dev/index.js

This file was deleted.

Loading

0 comments on commit 56af8d0

Please sign in to comment.