Skip to content

Commit

Permalink
Merge branch 'master' into sveltejsgh-5372
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich-Harris authored Jul 6, 2022
2 parents 66d1868 + 730bd3e commit b75dc48
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/tiny-flies-know.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

Allow server restart when config changed
18 changes: 12 additions & 6 deletions packages/kit/src/vite/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ function kit() {
/** @type {import('types').ManifestData} */
let manifest_data;

/** @type {boolean} */
let is_build;

/**
* @type {{
* build_dir: string;
Expand Down Expand Up @@ -121,14 +124,15 @@ function kit() {
vite_config = config;
vite_config_env = config_env;
svelte_config = await load_config();
is_build = config_env.command === 'build';

paths = {
build_dir: `${svelte_config.kit.outDir}/build`,
output_dir: `${svelte_config.kit.outDir}/output`,
client_out_dir: `${svelte_config.kit.outDir}/output/client/${svelte_config.kit.appDir}`
};

if (config_env.command === 'build') {
if (is_build) {
process.env.VITE_SVELTEKIT_APP_VERSION = svelte_config.kit.version.name;
process.env.VITE_SVELTEKIT_APP_VERSION_FILE = `${svelte_config.kit.appDir}/version.json`;
process.env.VITE_SVELTEKIT_APP_VERSION_POLL_INTERVAL = `${svelte_config.kit.version.pollInterval}`;
Expand Down Expand Up @@ -188,11 +192,13 @@ function kit() {
},

buildStart() {
rimraf(paths.build_dir);
mkdirp(paths.build_dir);
if (is_build) {
rimraf(paths.build_dir);
mkdirp(paths.build_dir);

rimraf(paths.output_dir);
mkdirp(paths.output_dir);
rimraf(paths.output_dir);
mkdirp(paths.output_dir);
}
},

async writeBundle(_options, bundle) {
Expand Down Expand Up @@ -321,7 +327,7 @@ function kit() {
},

closeBundle() {
if (svelte_config.kit.prerender.enabled) {
if (is_build && svelte_config.kit.prerender.enabled) {
// this is necessary to close any open db connections, etc.
// TODO: prerender in a subprocess so we can exit in isolation
// https://github.com/sveltejs/kit/issues/5306
Expand Down

0 comments on commit b75dc48

Please sign in to comment.