Advertisement
SpiderLordCoder1st

Untitled

Jun 9th, 2025
12
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. import staticAdapter from '@sveltejs/adapter-static';
  2. import fs from 'fs/promises';
  3. import path from 'path';
  4.  
  5. export default function (options = {}) {
  6. const baseAdapter = staticAdapter(options);
  7.  
  8. return {
  9. ...baseAdapter,
  10. /**
  11. * @param {import("@sveltejs/kit").Builder} builder
  12. */
  13. async adapt(builder) {
  14. await baseAdapter.adapt(builder);
  15.  
  16. const buildDir = 'build';
  17. const chunksDir = path.join(buildDir, '_app', 'immutable', 'chunks');
  18.  
  19. const files = await fs.readdir(chunksDir);
  20. const pathsFile = files.find(f => /^paths-\w+\.js$/.test(f));
  21.  
  22. if (pathsFile) {
  23. const filePath = path.join(chunksDir, pathsFile);
  24. const newContent = `
  25. export const base = (typeof window !== 'undefined' && window.__sveltekit_base) || '';
  26. export const assets = base;
  27. `;
  28. await fs.writeFile(filePath, newContent);
  29. }
  30. }
  31. };
  32. };
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement