Skip to content

Commit

Permalink
[chore] update build output location
Browse files Browse the repository at this point in the history
  • Loading branch information
benmccann committed Aug 3, 2021
1 parent 04045c2 commit ae4f8ed
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 12 deletions.
6 changes: 6 additions & 0 deletions .changeset/many-cups-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@sveltejs/adapter-node': patch
'@sveltejs/adapter-static': patch
---

[chore] update build output location
2 changes: 1 addition & 1 deletion documentation/docs/10-adapters.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default {
};
```

With this, [svelte-kit build](#command-line-interface-svelte-kit-build) will generate a self-contained Node app inside `build`. You can pass options to adapters, such as customising the output directory in `adapter-node`:
With this, [svelte-kit build](#command-line-interface-svelte-kit-build) will generate a self-contained Node app inside `.svelte-kit/node/build`. You can pass options to adapters, such as customising the output directory in `adapter-node`:

```diff
// svelte.config.js
Expand Down
4 changes: 2 additions & 2 deletions packages/adapter-node/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default {
kit: {
adapter: adapter({
// default options are shown
out: 'build',
out: '.svelte-kit/node/build',
precompress: false,
env: {
host: 'HOST',
Expand All @@ -29,7 +29,7 @@ export default {

### out

The directory to build the server to. It defaults to `build` — i.e. `node build` would start the server locally after it has been created.
The directory to build the server to. It defaults to `.svelte-kit/node/build` — i.e. `node .svelte-kit/node/build` would start the server locally after it has been created.

### precompress

Expand Down
8 changes: 4 additions & 4 deletions packages/adapter-node/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const pipe = promisify(pipeline);
* }} options
*/
export default function ({
out = 'build',
out = '.svelte-kit/node/build',
precompress,
env: { host: host_env = 'HOST', port: port_env = 'PORT' } = {},
esbuild: esbuildConfig
Expand All @@ -54,16 +54,16 @@ export default function ({

utils.log.minor('Building server');
const files = fileURLToPath(new URL('./files', import.meta.url));
utils.copy(files, '.svelte-kit/node');
utils.copy(files, '.svelte-kit/node/intermediate');
writeFileSync(
'.svelte-kit/node/env.js',
'.svelte-kit/node/intermediate/env.js',
`export const host = process.env[${JSON.stringify(
host_env
)}] || '0.0.0.0';\nexport const port = process.env[${JSON.stringify(port_env)}] || 3000;`
);
/** @type {BuildOptions} */
const defaultOptions = {
entryPoints: ['.svelte-kit/node/index.js'],
entryPoints: ['.svelte-kit/node/intermediate/index.js'],
outfile: join(out, 'index.js'),
bundle: true,
external: Object.keys(JSON.parse(readFileSync('package.json', 'utf8')).dependencies || {}),
Expand Down
2 changes: 1 addition & 1 deletion packages/adapter-node/src/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// TODO hardcoding the relative location makes this brittle
import { init, render } from '../output/server/app.js'; // eslint-disable-line import/no-unresolved
import { init, render } from '../../output/server/app.js'; // eslint-disable-line import/no-unresolved
import { host, port } from './env.js'; // eslint-disable-line import/no-unresolved
import { createServer } from './server';

Expand Down
6 changes: 3 additions & 3 deletions packages/adapter-static/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ export default {
kit: {
adapter: adapter({
// default options are shown
pages: 'build',
assets: 'build',
pages: '.svelte-kit/static/build',
assets: '.svelte-kit/static/build',
fallback: null
})
}
Expand All @@ -28,7 +28,7 @@ Unless you're in [SPA mode](#spa-mode), the adapter will attempt to prerender ev

### pages

The directory to write prerendered pages to. It defaults to `build`.
The directory to write prerendered pages to. It defaults to `.svelte-kit/static/build`.

### assets

Expand Down
2 changes: 1 addition & 1 deletion packages/adapter-static/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* fallback?: string;
* }} [opts]
*/
export default function ({ pages = 'build', assets = pages, fallback } = {}) {
export default function ({ pages = '.svelte-kit/static/build', assets = pages, fallback } = {}) {
/** @type {import('@sveltejs/kit').Adapter} */
const adapter = {
name: '@sveltejs/adapter-static',
Expand Down

0 comments on commit ae4f8ed

Please sign in to comment.