Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import staticAdapter from '@sveltejs/adapter-static';
- import fs from 'fs/promises';
- import path from 'path';
- export default function (options = {}) {
- const baseAdapter = staticAdapter(options);
- return {
- ...baseAdapter,
- /**
- * @param {import("@sveltejs/kit").Builder} builder
- */
- async adapt(builder) {
- await baseAdapter.adapt(builder);
- const buildDir = 'build';
- const chunksDir = path.join(buildDir, '_app', 'immutable', 'chunks');
- const files = await fs.readdir(chunksDir);
- const pathsFile = files.find(f => /^paths-\w+\.js$/.test(f));
- if (pathsFile) {
- const filePath = path.join(chunksDir, pathsFile);
- const newContent = `
- export const base = (typeof window !== 'undefined' && window.__sveltekit_base) || '';
- export const assets = base;
- `;
- await fs.writeFile(filePath, newContent);
- }
- }
- };
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement