zankhq / astro-starter

Astro starter template
https://astrostarter.zank.studio
MIT License
58 stars 11 forks source link

Dev Server Issues with Vite Transform Errors and CMS Access Problems #17

Closed deployn closed 3 months ago

deployn commented 11 months ago

I'm encountering a problem where the development server seems to be malfunctioning. After running npm install followed by npm run dev, I initially received several errors.

The first error is related to an unexpected token in a TypeScript file within an Astro component layout:

[vite] Internal server error: Transform failed with 1 error:
[...]/astro-starter/src/layouts/Layout.astro?astro&type=script&index=0&lang.ts:2:7: ERROR: Expected "(" but found "{"
  Plugin: vite:esbuild
  File: [...]/astro-starter/src/layouts/Layout.astro?astro&type=script&index=0&lang.ts

  Expected "(" but found "{"
  1  |  ---
  2  |  import { getLocale } from "astro-i18n-aut";
     |         ^
  3  |  import { ViewTransitions } from "astro:transitions";
  4  |  import BaseHead from "@components/BaseHead.astro";

The last one is from a PostCSS process failure, indicating an "Unknown word" in a style block within an Astro component:

[vite] Internal server error: [postcss] [...]/astro-starter/src/components/Link.astro?astro&type=style&index=0&lang.css:2:10: Unknown word
  Plugin: vite:css
  File: [...]/astro-starter/src/components/Link.astro?astro&type=style&index=0&lang.css:2:10
  1  |  ---
  2  |  import { getLocaleUrlPrefix } from "astro-i18n-aut";
     |            ^
  3  |
  4  |  const localeUrlPrefix = getLocaleUrlPrefix(Astro.url);

There are other similar errors, but eventually, the server did start successfully. However, I am unable to access the CMS at /admin/index. Additionally, the custom 404 page is not displaying as expected. Below is the console log that appears when attempting to access the CMS:

workbox Router is responding to: /admin/index.html
workbox-5357ef54.js:62 Found a route to handle this request: 
NavigationRoute
handler: {handle: f}
match: options => this._match(options)
method: "GET"
_allowlist: [/^\//]
_denylist: []
[[Prototype]]: Route

image

SHA-Version: 45a253d00f90e1aa68ce6a159c60eb52eea45cf2

zanhk commented 11 months ago

@deployn This is probably an errore related to the service worker

can you try unregister the service worker and reload the page to see if the error persist?

zanhk commented 11 months ago

I will probably disable the service worker for local development as it caused trouble to me as well

zanhk commented 11 months ago

@deployn I definetly need to do more testing on that, probably some problem on the service worker, now I disable it until i figure out the problem

deployn commented 11 months ago

can you try unregister the service worker and reload the page to see if the error persist?

This worked, but I have to do this after every click.

zanhk commented 11 months ago

@deployn I will make some test the coming week about that, for now you can try the latest version where I disabled the service worker

zanhk commented 3 months ago

Should be fixed