Skip to content

Commit

Permalink
Implement build
Browse files Browse the repository at this point in the history
  • Loading branch information
benmccann committed May 30, 2022
1 parent 2d335b7 commit 32acbe4
Show file tree
Hide file tree
Showing 5 changed files with 200 additions and 208 deletions.
32 changes: 9 additions & 23 deletions packages/kit/src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ 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';
import { logger } from './core/utils.js';

/** @param {unknown} e */
function handle_error(e) {
Expand Down Expand Up @@ -158,31 +157,18 @@ prog
.action(async ({ verbose }) => {
try {
process.env.NODE_ENV = process.env.NODE_ENV || 'production';
const config = await load_config();

const log = logger({ verbose });

const { build } = await import('./core/build/index.js');
const { build_data, prerendered } = await build(config, { log });

console.log(
`\nRun ${colors.bold().cyan('npm run preview')} to preview your production build locally.`
);

if (config.kit.adapter) {
const { adapt } = await import('./core/adapt/index.js');
await adapt(config, build_data, prerendered, { log });
process.env.VERBOSE = verbose;

// this is necessary to close any open db connections, etc
process.exit(0);
}
const svelte_config = await load_config();
const { plugins } = await import('./vite/plugin.js');
const vite_config = await svelte_config.kit.vite();

console.log(colors.bold().yellow('\nNo adapter specified'));
/** @type {import('vite').UserConfig} */
const config = {
plugins: [...(vite_config.plugins || []), await plugins(svelte_config)]
};

// prettier-ignore
console.log(
`See ${colors.bold().cyan('https://kit.svelte.dev/docs/adapters')} to learn how to configure your app to run on the platform of your choosing`
);
await vite.build(config);
} catch (error) {
handle_error(error);
}
Expand Down
79 changes: 0 additions & 79 deletions packages/kit/src/core/build/build_client.js

This file was deleted.

91 changes: 0 additions & 91 deletions packages/kit/src/core/build/index.js

This file was deleted.

13 changes: 2 additions & 11 deletions packages/kit/src/core/build/utils.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { svelte } from '@sveltejs/vite-plugin-svelte';
import * as vite from 'vite';
import { svelte } from '../../vite/plugin.js';
import { get_aliases } from '../utils.js';

/**
Expand Down Expand Up @@ -74,16 +74,7 @@ export const get_default_config = function ({ client_out_dir, config, input, out
},
ssr
},
plugins: [
svelte({
...config,
compilerOptions: {
...config.compilerOptions,
hydratable: !!config.kit.browser.hydrate
},
configFile: false
})
],
plugins: [svelte(config)],
// prevent Vite copying the contents of `config.kit.files.assets`,
// if it happens to be 'public' instead of 'static'
publicDir: false,
Expand Down
Loading

0 comments on commit 32acbe4

Please sign in to comment.