You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/adapter-netlify/README.md
+20-3Lines changed: 20 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,14 +27,16 @@ export default {
27
27
};
28
28
```
29
29
30
-
Then, make sure you have a [netlify.toml](https://docs.netlify.com/configure-builds/file-based-configuration) file in the project root. This will determine where to write static assets and functions to based on the `build.publish` settings, as per this sample configuration:
30
+
Then, make sure you have a [netlify.toml](https://docs.netlify.com/configure-builds/file-based-configuration) file in the project root. This will determine where to write static assets based on the `build.publish` settings, as per this sample configuration:
31
31
32
32
```toml
33
33
[build]
34
34
command = "npm run build"
35
-
publish = "build/publish/"
35
+
publish = "build"
36
36
```
37
37
38
+
If the `netlify.toml` file or the `build.publish` value is missing, a default value of `"build"` will be used. Note that if you have set the publish directory in the Netlify UI to something else then you will need to set it in `netlify.toml` too, or use the default value of `"build"`.
39
+
38
40
## Netlify alternatives to SvelteKit functionality
39
41
40
42
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.
@@ -52,6 +54,20 @@ During compilation a required "catch all" redirect rule is automatically appende
52
54
2. Netlify's build bot parses your HTML files at deploy time, which means your form must be [prerendered](https://kit.svelte.dev/docs#ssr-and-javascript-prerender) as HTML. You can either add `export const prerender = true` to your `contact.svelte` to prerender just that page or set the `kit.prerender.force: true` option to prerender all pages.
53
55
3. If your Netlify form has a [custom success message](https://docs.netlify.com/forms/setup/#success-messages) like `<form netlify ... action="/success">` then ensure the corresponding `/routes/success.svelte` exists and is prerendered.
54
56
57
+
### Using Netlify Functions
58
+
59
+
[Netlify Functions](https://docs.netlify.com/functions/overview/) can be used alongside your SvelteKit routes. If you would like to add them to your site, you should create a directory for them and add the configuration to your `netlify.toml` file. For example:
60
+
61
+
```toml
62
+
[build]
63
+
command = "npm run build"
64
+
publish = "build"
65
+
66
+
[functions]
67
+
directory = "functions"
68
+
node_bundler = "esbuild"
69
+
```
70
+
55
71
## Advanced Configuration
56
72
57
73
### esbuild
@@ -76,7 +92,8 @@ The default options for this version are as follows:
76
92
```js
77
93
{
78
94
entryPoints: ['.svelte-kit/netlify/entry.js'],
79
-
outfile:`pathToFunctionsFolder/render/index.js`,
95
+
// This is Netlify's internal functions directory, not the one for user functions.
'The publish directory cannot be set to the site root. Please change it to "build" in netlify.toml.'
99
+
);
100
+
}
101
+
returnnetlify_config.build.publish;
93
102
}
94
103
95
-
// TODO offer to create one?
96
-
thrownewError(
97
-
'Missing a netlify.toml file. Consult https://github.com/sveltejs/kit/tree/master/packages/adapter-netlify#configuration'
104
+
utils.log.warn(
105
+
'No netlify.toml found. Using default publish directory. Consult https://github.com/sveltejs/kit/tree/master/packages/adapter-netlify#configuration for more details '
0 commit comments