Skip to content

Commit

Permalink
feat(hybrid): overwrite static files
Browse files Browse the repository at this point in the history
  • Loading branch information
natemoo-re committed Nov 3, 2022
1 parent f912c9a commit 1c7cd11
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 15 deletions.
8 changes: 1 addition & 7 deletions examples/minimal/astro.config.mjs
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
import { defineConfig } from 'astro/config';
import node from '@astrojs/node';

// https://astro.build/config
export default defineConfig({
output: 'server',
adapter: node({
mode: 'standalone'
})
});
export default defineConfig({});
5 changes: 0 additions & 5 deletions examples/minimal/src/pages/api/endpoint.ts

This file was deleted.

1 change: 0 additions & 1 deletion examples/minimal/src/pages/index.astro
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---
export const output = 'static';
---

<html lang="en">
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/core/build/static-build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ async function cleanStaticOutput(opts: StaticBuildOptions, internals: BuildInter
if (!allStaticFiles.has(filename.replace('server/', ''))) {
return;
}
// TODO: update file
await fs.promises.writeFile(url, 'export const _ = null;', { encoding: 'utf-8' });
})
);
// Map directories heads from the .mjs files
Expand Down
7 changes: 6 additions & 1 deletion packages/astro/src/core/build/vite-plugin-ssr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { pagesVirtualModuleId } from '../app/index.js';
import { serializeRouteData } from '../routing/index.js';
import { addRollupInput } from './add-rollup-input.js';
import { eachServerPageData, eachStaticPageData, sortedCSS } from './internal.js';
import { getOutFile, getOutFolder } from './common.js';

export const virtualModuleId = '@astrojs-ssr-virtual-entry';
const resolvedVirtualModuleId = '\0' + virtualModuleId;
Expand Down Expand Up @@ -134,12 +135,16 @@ function buildManifest(
}

for (const pageData of eachStaticPageData(internals)) {
const outFolder = getOutFolder(opts.settings.config, pageData.route.pathname!, pageData.route.type);
const outFile = getOutFile(opts.settings.config, outFolder, pageData.route.pathname!, pageData.route.type);
const file = outFile.toString().replace(opts.settings.config.build.client.toString(), '');
routes.push({
file: `../client/${pageData.route.pathname}.html`,
file,
links: [],
scripts: [],
routeData: serializeRouteData(pageData.route, settings.config.trailingSlash),
});
staticFiles.push(file);
}

for (const pageData of eachServerPageData(internals)) {
Expand Down

0 comments on commit 1c7cd11

Please sign in to comment.