iamshaunjp / pwa-tutorial

Course files for the progressive web app tutorial series on The Net Ninja YouTube channel.
386 stars 362 forks source link

Error loading resources from sub-folders. #8

Open pcarpovich opened 4 years ago

pcarpovich commented 4 years ago

I was using a lot the samples to build my own PWA app, I don't know what changed on my VSCode that I cannot run the sample code with Live Server. I get a weird problem with subfolders.

If I remove the first slash from de references it works:

Example: If I change "" into ""

I'll appreciate if someone can give me some help to solve this issue, it happen to me not just with this sample project but also with my own projects.

Capture1 Capture2

pcarpovich commented 4 years ago

Sorry code sample doesn't show, here it is:

Removing the first slash of de ref, it works

This <link type="text/css" href="css/materialize.min.css" rel="stylesheet"> instead of <link type="text/css" href="/css/materialize.min.css" rel="stylesheet">

It's the same for any reference to css, js, icons.

Thanks!

pcarpovich commented 4 years ago

OK, I could solve the problem.

I created a folder (.vscode) on the root directory (of the project) and add a file "settings.json" with the folowing config:

{ "liveServer.settings.port": 5505, "liveServer.settings.root": "/public" }

I used this port just to be sure that Live Server takes this configuration.

image

As you can see, now all the files are visible.