Skip to content

Commit

Permalink
Update out directories for Netlify Functions (#3381)
Browse files Browse the repository at this point in the history
* Change out directories for Netlify Functions

* Changeset

* Update test
  • Loading branch information
sarahetter authored May 16, 2022
1 parent 0259d76 commit 43d9222
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/eight-feet-reflect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/netlify': minor
---

Updating out directories for Netlify Functions
2 changes: 1 addition & 1 deletion packages/integrations/netlify/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
4 changes: 2 additions & 2 deletions packages/integrations/netlify/src/integration-functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) => {
Expand All @@ -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);
Expand Down
5 changes: 4 additions & 1 deletion packages/integrations/netlify/test/functions/cookies.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 43d9222

Please sign in to comment.