question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Static Adapter not generating index.html with proper script links for GH-pages deploy

See original GitHub issue

Describe the bug

I have been trying to get a portfolio using svelte to deploy to GH-pages and no matter what configuration I use in the adapter I can’t get it to load the .js files on the deployed site post build. The index.html generated in the build has /_app/immutable/{generatedfile}.js as failing to load.

Reproduction

I was able to reproduce the bug with a skeleton svelte app that I added two dummy pages and only the dependencies needed to use the static adapter. I am seeing the same results. See screenshots below:

index.html generated from build image

svelte.config.js image

console on github pages with js files failing to load image

Logs

Logs from the build and deploy

$ npm run deploy

> gh-pages-issue-recreation@0.0.1 deploy
> npm run build && npx gh-pages -d ./build -t true


> gh-pages-issue-recreation@0.0.1 build
> rm -rf build && vite build && touch ./build/.nojekyll

(node:16408) ExperimentalWarning: stream/web is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
vite v3.0.2 building for production...
transforming...
✓ 15 modules transformed.
rendering chunks...
.svelte-kit/output/client/manifest.json                                     1.74 KiB
.svelte-kit/output/client/_app/immutable/layout.svelte-9147df0b.js          0.53 KiB / gzip: 0.35 KiB
.svelte-kit/output/client/_app/immutable/error.svelte-7d1ddec6.js           1.56 KiB / gzip: 0.75 KiB
.svelte-kit/output/client/_app/immutable/pages/index.svelte-ba0114b5.js     0.80 KiB / gzip: 0.47 KiB
.svelte-kit/output/client/_app/immutable/pages/lib/nav.svelte-ad49efb2.js   0.81 KiB / gzip: 0.44 KiB
.svelte-kit/output/client/_app/immutable/start-cd7304e7.js                  24.22 KiB / gzip: 9.04 KiB
.svelte-kit/output/client/_app/immutable/pages/page.svelte-f5bdb174.js      0.62 KiB / gzip: 0.40 KiB
.svelte-kit/output/client/_app/immutable/chunks/index-03969575.js           6.85 KiB / gzip: 2.80 KiB
vite v3.0.2 building SSR bundle for production...
transforming...
✓ 13 modules transformed.
Generated an empty chunk: "hooks"
rendering chunks...
.svelte-kit/output/server/manifest.json                             1.50 KiB
.svelte-kit/output/server/index.js                                  76.23 KiB
.svelte-kit/output/server/entries/fallbacks/layout.svelte.js        0.25 KiB
.svelte-kit/output/server/entries/fallbacks/error.svelte.js         0.74 KiB
.svelte-kit/output/server/entries/pages/index.svelte.js             0.34 KiB
.svelte-kit/output/server/entries/pages/lib/nav.svelte.js           0.32 KiB
.svelte-kit/output/server/entries/pages/page.svelte.js              0.26 KiB
.svelte-kit/output/server/_app/immutable/chunks/index-3e01a4ca.js   2.61 KiB
.svelte-kit/output/server/_app/immutable/chunks/hooks-bced8853.js   0.00 KiB
(node:16408) ExperimentalWarning: buffer.Blob is an experimental feature. This feature could change at any time

Run npm run preview to preview your production build locally.

> Using @sveltejs/adapter-static
  Wrote site to "build"
  ✔ done
Published

System Info

System:
    OS: Windows 10 10.0.19043
    CPU: (4) x64 Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz
    Memory: 1.62 GB / 7.81 GB
  Binaries:
    Node: 16.13.2 - C:\Program Files\nodejs\node.EXE
    npm: 8.1.2 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Chrome: 103.0.5060.114
    Edge: Spartan (44.19041.1266.0), Chromium (103.0.1264.62)
    Internet Explorer: 11.0.19041.1566
  npmPackages:
    @sveltejs/adapter-auto: next => 1.0.0-next.63
    @sveltejs/adapter-static: ^1.0.0-next.38 => 1.0.0-next.38
    @sveltejs/kit: next => 1.0.0-next.390
    svelte: ^3.44.0 => 3.49.0
    vite: ^3.0.0 => 3.0.2

Severity

blocking all usage of SvelteKit

Additional Information

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
frederikhorscommented, Jul 23, 2022
0reactions
tmallzcommented, Aug 1, 2022

Hey, I ran into the same issue, until I noticed that paths is a property of kit, not config.

So instead of

config={
kit{},
paths{}
}

it has to be

config={
kit{ paths{} }
};

in your exact case it would be

const config = {
  kit: {
    adapter: adapter({
      pages: 'build',
      assets: 'build',
      fallback: 'index.html',
      trailingSlash: 'always',
      precompress: true,
    }),
    paths: {
      base: dev ? '' : '/SPA-build-not-adding-repo-name',
    },
  }
};

Check out my fork of your repo, as you can see files in /build have the correct paths and the working hosted site

This sovled the issue for me. Thank you @p-jeff! I will close this issue now

Read more comments on GitHub >

github_iconTop Results From Across the Web

adapter-static not rendering index.html by default #4842
I created a skeleton project via npm init svelte . Switched to adapter-static to build it. The output didn't contain an html file....
Read more >
jekyll - js and css not loading when hosting next application on ...
I am 404 for static assets. Example repo: https://github.com/ajaymathur/ajaymathur.github.io Master branch is hosted and dev branch is for ...
Read more >
Fixing Broken Relative Links on GitHub Pages - Pluralsight
This guide will walk you through options for solving this issue. We will look at solutions for websites packaged with Webpack and React...
Read more >
SvelteKit & GitHub Pages (English) - Strani Anelli
First I create a new project based on SvelteKit by typing: ... I add the script on package.json : ... To publish on...
Read more >
r/sveltejs icon - Reddit
Having trouble deploying a static svelte app on github pages ... There's no index page (index.html) at the root of your "pokedex" repo, ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found