Skip to content

Commit

Permalink
Ensure vite.config.js works on Windows (#5265)
Browse files Browse the repository at this point in the history
* Ensure vite.config.js works on Windows

* format

* try to fix windows

* changeset
  • Loading branch information
benmccann authored Jun 27, 2022
1 parent fb295fe commit 713157a
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 14 deletions.
5 changes: 5 additions & 0 deletions .changeset/neat-monkeys-dream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

[fix] support vite.config.js on Windows
5 changes: 3 additions & 2 deletions packages/kit/src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import path from 'path';
import colors from 'kleur';
import sade from 'sade';
import * as vite from 'vite';
import { load_config } from './core/config/index.js';
import { networkInterfaces, release } from 'os';
import { pathToFileURL } from 'url';
import { load_config } from './core/config/index.js';
import { coalesce_to_error } from './utils/error.js';

/** @param {unknown} e */
Expand Down Expand Up @@ -289,7 +290,7 @@ export async function get_vite_config(svelte_config) {
for (const file of ['vite.config.js', 'vite.config.mjs', 'vite.config.cjs']) {
if (fs.existsSync(file)) {
// TODO warn here if config.kit.vite was specified
const module = await import(path.resolve(file));
const module = await import(pathToFileURL(file).toString());
return {
...module.default,
configFile: false
Expand Down
12 changes: 0 additions & 12 deletions packages/kit/test/apps/options-2/svelte.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import * as path from 'path';

/** @type {import('@sveltejs/kit').Config} */
const config = {
kit: {
Expand All @@ -8,16 +6,6 @@ const config = {
},
serviceWorker: {
register: false
},
vite: {
server: {
// TODO: required to support ipv6, remove on vite 3
// https://github.com/vitejs/vite/issues/7075
host: 'localhost',
fs: {
allow: [path.resolve('../../../src')]
}
}
}
}
};
Expand Down
17 changes: 17 additions & 0 deletions packages/kit/test/apps/options-2/vite.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import * as path from 'path';
import { sveltekit } from '@sveltejs/kit/experimental/vite';

/** @type {import('vite').UserConfig} */
const config = {
plugins: [sveltekit()],
server: {
// TODO: required to support ipv6, remove on vite 3
// https://github.com/vitejs/vite/issues/7075
host: 'localhost',
fs: {
allow: [path.resolve('../../../src')]
}
}
};

export default config;

0 comments on commit 713157a

Please sign in to comment.