* fix(#5723): build prerendered pages with Netlify edge functions * chore: add changeset Co-authored-by: Nate Moore <nate@astro.build>
This commit is contained in:
parent
dc2496f702
commit
8f1ae06e58
2 changed files with 5 additions and 15 deletions
5
.changeset/spicy-parrots-beam.md
Normal file
5
.changeset/spicy-parrots-beam.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'@astrojs/netlify': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix issue with prerendered pages when using `edge-functions` adapter
|
|
@ -117,18 +117,6 @@ export function netlifyEdgeFunctions({ dist }: NetlifyEdgeFunctionsOptions = {})
|
||||||
name: '@astrojs/netlify/edge-functions',
|
name: '@astrojs/netlify/edge-functions',
|
||||||
hooks: {
|
hooks: {
|
||||||
'astro:config:setup': ({ config, updateConfig }) => {
|
'astro:config:setup': ({ config, updateConfig }) => {
|
||||||
// Add a plugin that shims the global environment.
|
|
||||||
const injectPlugin: VitePlugin = {
|
|
||||||
name: '@astrojs/netlify/plugin-inject',
|
|
||||||
generateBundle(_options, bundle) {
|
|
||||||
if (_buildConfig.serverEntry in bundle) {
|
|
||||||
const chunk = bundle[_buildConfig.serverEntry];
|
|
||||||
if (chunk && chunk.type === 'chunk') {
|
|
||||||
chunk.code = `globalThis.process = { argv: [], env: {}, };${chunk.code}`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
};
|
|
||||||
const outDir = dist ?? new URL('./dist/', config.root);
|
const outDir = dist ?? new URL('./dist/', config.root);
|
||||||
updateConfig({
|
updateConfig({
|
||||||
outDir,
|
outDir,
|
||||||
|
@ -137,9 +125,6 @@ export function netlifyEdgeFunctions({ dist }: NetlifyEdgeFunctionsOptions = {})
|
||||||
server: new URL('./.netlify/edge-functions/', config.root),
|
server: new URL('./.netlify/edge-functions/', config.root),
|
||||||
serverEntry: 'entry.js',
|
serverEntry: 'entry.js',
|
||||||
},
|
},
|
||||||
vite: {
|
|
||||||
plugins: [injectPlugin],
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
'astro:config:done': ({ config, setAdapter }) => {
|
'astro:config:done': ({ config, setAdapter }) => {
|
||||||
|
|
Loading…
Reference in a new issue