Update out directories for Netlify Functions (#3381)

* Change out directories for Netlify Functions

* Changeset

* Update test
This commit is contained in:
Sarah Etter 2022-05-16 14:44:21 -04:00 committed by GitHub
parent 0259d7658b
commit 43d922277a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 4 deletions

View file

@ -0,0 +1,5 @@
---
'@astrojs/netlify': minor
---
Updating out directories for Netlify Functions

View file

@ -39,7 +39,7 @@ export default defineConfig({
### dist
For Netlify Functions, we build to a `netlify` directory at the base of your project. In the case of Netlify Edge Functions, we build to a `dist` directory at the base of your project. To change this, use the `dist` option:
We build to a `dist` directory at the base of your project. To change this, use the `dist` option:
```js
import { defineConfig } from 'astro/config';

View file

@ -24,7 +24,7 @@ function netlifyFunctions({ dist }: NetlifyFunctionsOptions = {}): AstroIntegrat
if (dist) {
config.outDir = dist;
} else {
config.outDir = new URL('./netlify/', config.root);
config.outDir = new URL('./dist/', config.root);
}
},
'astro:config:done': ({ config, setAdapter }) => {
@ -34,7 +34,7 @@ function netlifyFunctions({ dist }: NetlifyFunctionsOptions = {}): AstroIntegrat
'astro:build:start': async ({ buildConfig }) => {
entryFile = buildConfig.serverEntry.replace(/\.m?js/, '');
buildConfig.client = _config.outDir;
buildConfig.server = new URL('./functions/', _config.outDir);
buildConfig.server = new URL('./.netlify/functions-internal/', _config.root);
},
'astro:build:done': async ({ routes, dir }) => {
await createRedirects(routes, dir, entryFile, false);

View file

@ -24,7 +24,10 @@ describe('Cookies', () => {
});
it('Can set multiple', async () => {
const entryURL = new URL('./fixtures/cookies/dist/functions/entry.mjs', import.meta.url);
const entryURL = new URL(
'./fixtures/cookies/.netlify/functions-internal/entry.mjs',
import.meta.url
);
const { handler } = await import(entryURL);
const resp = await handler({
httpMethod: 'POST',