Skip to content

Commit 94b34fa

Browse files
authored
[breaking] standardize final output dir as /build (vs /.svelte-kit) (#2109)
1 parent be30a93 commit 94b34fa

File tree

16 files changed

+35
-27
lines changed

16 files changed

+35
-27
lines changed

.changeset/funny-trainers-hammer.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
'@sveltejs/adapter-netlify': patch
3+
'@sveltejs/adapter-node': patch
4+
'@sveltejs/adapter-static': patch
5+
'create-svelte': patch
6+
---
7+
8+
[breaking] standardize final output dir as /build (vs /.svelte-kit)

documentation/docs/10-adapters.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export default {
1717
};
1818
```
1919

20-
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`:
20+
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`:
2121

2222
```diff
2323
// svelte.config.js

documentation/docs/80-adapter-api.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,6 @@ Within the `adapt` method, there are a number of things that an adapter should d
3434
- Call `utils.prerender`
3535
- Put the user's static files and the generated JS/CSS in the correct location for the target platform
3636

37-
If possible, we recommend putting the adapter output under `'.svelte-kit/' + adapterName` with any intermediate output under `'.svelte-kit/' + adapterName + '/intermediate'`.
37+
If possible, we recommend putting the adapter output under the `build/` directory with any intermediate output placed under `'.svelte-kit/' + adapterName`.
3838

3939
> The adapter API may change before 1.0.

packages/adapter-netlify/README.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,10 @@ Then, make sure you have a [netlify.toml](https://docs.netlify.com/configure-bui
3232
```toml
3333
[build]
3434
command = "npm run build"
35-
publish = ".svelte-kit/netlify/build/"
36-
functions = ".svelte-kit/netlify/functions/"
35+
publish = "build/publish/"
36+
functions = "build/functions/"
3737
```
3838

39-
In this example, we placed the `build` and `functions` folders under `.svelte-kit/netlify`. If you specify another location, you will probably also want to add them to your `.gitignore`.
40-
4139
## Netlify alternatives to SvelteKit functionality
4240

4341
You may build your app using functionality provided directly by SvelteKit without relying on any Netlify functionality. Using the SvelteKit versions of these features will allow them to be used in dev mode, tested with integration tests, and to work with other adapters should you ever decide to switch away from Netlify. However, in some scenarios you may find it beneficial to use the Netlify versions of these features. One example would be if you're migrating an app that's already hosted on Netlify to SvelteKit.

packages/adapter-netlify/files/entry.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// TODO hardcoding the relative location makes this brittle
2-
import { init, render } from '../../output/server/app.js'; // eslint-disable-line import/no-unresolved
2+
import { init, render } from '../output/server/app.js'; // eslint-disable-line import/no-unresolved
33
import { isContentTypeTextual } from '@sveltejs/kit/adapter-utils'; // eslint-disable-line import/no-unresolved
44

55
init();

packages/adapter-netlify/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ export default function (options) {
2727
const files = fileURLToPath(new URL('./files', import.meta.url));
2828

2929
utils.log.minor('Generating serverless function...');
30-
utils.copy(join(files, 'entry.js'), '.svelte-kit/netlify/intermediate/entry.js');
30+
utils.copy(join(files, 'entry.js'), '.svelte-kit/netlify/entry.js');
3131

3232
/** @type {BuildOptions} */
3333
const defaultOptions = {
34-
entryPoints: ['.svelte-kit/netlify/intermediate/entry.js'],
34+
entryPoints: ['.svelte-kit/netlify/entry.js'],
3535
outfile: join(functions, 'render/index.js'),
3636
bundle: true,
3737
inject: [join(files, 'shims.js')],

packages/adapter-node/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export default {
1414
kit: {
1515
adapter: adapter({
1616
// default options are shown
17-
out: '.svelte-kit/node/build',
17+
out: 'build',
1818
precompress: false,
1919
env: {
2020
host: 'HOST',
@@ -29,7 +29,7 @@ export default {
2929

3030
### out
3131

32-
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.
32+
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.
3333

3434
### precompress
3535

packages/adapter-node/index.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const pipe = promisify(pipeline);
3232
* }} options
3333
*/
3434
export default function ({
35-
out = '.svelte-kit/node/build',
35+
out = 'build',
3636
precompress,
3737
env: { host: host_env = 'HOST', port: port_env = 'PORT' } = {},
3838
esbuild: esbuildConfig
@@ -54,16 +54,16 @@ export default function ({
5454

5555
utils.log.minor('Building server');
5656
const files = fileURLToPath(new URL('./files', import.meta.url));
57-
utils.copy(files, '.svelte-kit/node/intermediate');
57+
utils.copy(files, '.svelte-kit/node');
5858
writeFileSync(
59-
'.svelte-kit/node/intermediate/env.js',
59+
'.svelte-kit/node/env.js',
6060
`export const host = process.env[${JSON.stringify(
6161
host_env
6262
)}] || '0.0.0.0';\nexport const port = process.env[${JSON.stringify(port_env)}] || 3000;`
6363
);
6464
/** @type {BuildOptions} */
6565
const defaultOptions = {
66-
entryPoints: ['.svelte-kit/node/intermediate/index.js'],
66+
entryPoints: ['.svelte-kit/node/index.js'],
6767
outfile: join(out, 'index.js'),
6868
bundle: true,
6969
external: Object.keys(JSON.parse(readFileSync('package.json', 'utf8')).dependencies || {}),

packages/adapter-node/rollup.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export default [
1111
sourcemap: true
1212
},
1313
plugins: [nodeResolve(), commonjs(), json()],
14-
external: ['../../output/server/app.js', './env.js', ...require('module').builtinModules]
14+
external: ['../output/server/app.js', './env.js', ...require('module').builtinModules]
1515
},
1616
{
1717
input: 'src/shims.js',

packages/adapter-node/src/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// TODO hardcoding the relative location makes this brittle
2-
import { init, render } from '../../output/server/app.js'; // eslint-disable-line import/no-unresolved
2+
import { init, render } from '../output/server/app.js'; // eslint-disable-line import/no-unresolved
33
import { host, port } from './env.js'; // eslint-disable-line import/no-unresolved
44
import { createServer } from './server';
55

packages/adapter-static/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ export default {
1414
kit: {
1515
adapter: adapter({
1616
// default options are shown
17-
pages: '.svelte-kit/static/build',
18-
assets: '.svelte-kit/static/build',
17+
pages: 'build',
18+
assets: 'build',
1919
fallback: null
2020
})
2121
}
@@ -28,7 +28,7 @@ Unless you're in [SPA mode](#spa-mode), the adapter will attempt to prerender ev
2828

2929
### pages
3030

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

3333
### assets
3434

packages/adapter-static/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* fallback?: string;
66
* }} [opts]
77
*/
8-
export default function ({ pages = '.svelte-kit/static/build', assets = pages, fallback } = {}) {
8+
export default function ({ pages = 'build', assets = pages, fallback } = {}) {
99
/** @type {import('@sveltejs/kit').Adapter} */
1010
const adapter = {
1111
name: '@sveltejs/adapter-static',

packages/adapter-static/test/test.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { run } from './utils.js';
44

55
run('prerendered', (test) => {
66
test('generates HTML files', ({ cwd }) => {
7-
assert.ok(fs.existsSync(`${cwd}/.svelte-kit/static/build/index.html`));
7+
assert.ok(fs.existsSync(`${cwd}/build/index.html`));
88
});
99

1010
test('prerenders content', async ({ base, page }) => {
@@ -15,15 +15,15 @@ run('prerendered', (test) => {
1515

1616
run('spa', (test) => {
1717
test('generates a fallback page', ({ cwd }) => {
18-
assert.ok(fs.existsSync(`${cwd}/.svelte-kit/static/build/200.html`));
18+
assert.ok(fs.existsSync(`${cwd}/build/200.html`));
1919
});
2020

2121
test('does not prerender pages without prerender=true', ({ cwd }) => {
22-
assert.ok(!fs.existsSync(`${cwd}/.svelte-kit/static/build/index.html`));
22+
assert.ok(!fs.existsSync(`${cwd}/build/index.html`));
2323
});
2424

2525
test('prerenders page with prerender=true', ({ cwd }) => {
26-
assert.ok(fs.existsSync(`${cwd}/.svelte-kit/static/build/about/index.html`));
26+
assert.ok(fs.existsSync(`${cwd}/build/about/index.html`));
2727
});
2828

2929
test('renders content in fallback page when JS runs', async ({ base, page }) => {

packages/adapter-static/test/utils.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export function run(app, callback) {
3131
const cwd = fileURLToPath(new URL(`apps/${app}`, import.meta.url));
3232
const cli_path = fileURLToPath(new URL('../../kit/src/cli.js', import.meta.url));
3333

34-
rimraf(`${cwd}/.svelte-kit/static/build`);
34+
rimraf(`${cwd}/build`);
3535

3636
await spawn(`"${process.execPath}" ${cli_path} build`, {
3737
cwd,
@@ -41,7 +41,7 @@ export function run(app, callback) {
4141

4242
context.cwd = cwd;
4343
context.port = await ports.find(4000);
44-
const handler = sirv(`${cwd}/.svelte-kit/static/build`, {
44+
const handler = sirv(`${cwd}/build`, {
4545
single: '200.html'
4646
});
4747
context.server = await create_server(context.port, handler);
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.DS_Store
22
node_modules
3+
/build
34
/.svelte-kit
45
/package
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.DS_Store
22
node_modules
3+
/build
34
/.svelte-kit
45
/package

0 commit comments

Comments
 (0)