Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write prerendered files to public dir #200

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ import {
parseFirebaseConfiguration,
} from './utils.js';

const adapterName = 'svelte-adapter-firebase';

/** @type {import('.')} **/
const entrypoint = function (options = {}) {
return {
name: 'svelte-adapter-firebase',
name: adapterName,
async adapt(builder) {
const {
esbuildOptions = undefined,
Expand All @@ -33,7 +35,7 @@ const entrypoint = function (options = {}) {
files: fileURLToPath(new URL('files', import.meta.url)),
serverDirname: functions.name ?? 'svelteKit',
serverPath: path.join(functions.source, path.dirname(functionsPackageJson.main), functions.name ?? 'svelteKit'),
tmp: builder.getBuildDirectory('.svelte-kit'),
tmp: builder.getBuildDirectory(adapterName),
};
const ssrFunc = {
entrypoint: path.join(functions.source, functionsPackageJson.main),
Expand Down Expand Up @@ -94,17 +96,21 @@ const entrypoint = function (options = {}) {
builder.writeClient(publicDir);

builder.log.minor(logRelativeDir('Prerendering static pages to', publicDir));
writeFileSync(`${dirs.tmp}/manifest.js`, `export const manifest = ${builder.generateManifest({
builder.writePrerendered(publicDir);

const manifest = builder.generateManifest({
relativePath,
})};\n`);
});

writeFileSync(`${dirs.tmp}/manifest.js`, `export const manifest = ${manifest};\n`);
builder.log.minor('Writing routes...');

builder.mkdirp(`${dirs.tmp}/config`);
writeFileSync(
`${dirs.tmp}/config/routes.json`,
JSON.stringify([
{
src: `/${builder.appDir}/.+`,
src: `/${builder.config.kit.appDir}/.+`,
headers: {
'cache-control': 'public, immutable, max-age=31536000',
},
Expand Down
3 changes: 2 additions & 1 deletion tests/end-to-end/scaffold/firebase.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"source": "**",
"function": "sveltekit"
}
]
],
"cleanUrls": true
},
"functions": {
"source": "functions"
Expand Down