ga-wdi-exercises/project4

CSS stylesheets won't load as resource

Closed this issue · 4 comments

cwcox commented

repo link = https://github.com/cwcox/taylor

Style sheet are linked in index.html but do not effect the browser view and do not get loaded as resources (based on the dev tools).

I believe it may have something to do with the routes defined in index.js.

However, I have also tried inline styling and that does show up either.

jsm13 commented

Got a couple things going on here:

  1. In index.js the line app.use('/assets', express.static('public')) means any requests coming into /assets/* should look for static assets (files with extensions html, js, css, etc) in the public/ directory. This means a request to localhost:3000/assets/css/index.css will look for a file in public/css/index.css. The file is actually at public/assets/css/index.css so the request needs to be made to localhost:3000/assets/assets/css/index.css or the path /assets/assets/css/index.css. This is a little weird so you might just want to get rid of the assets directory in public.

  2. These lines:

    <link rel="stylesheet" src="css/index.css">
    <link rel="stylesheet" ng-href="./css/taylor_index.css">

need to be:

    <link rel="stylesheet" href="/assets/assets/css/index.css">
    <link rel="stylesheet" href="/assets/assets/css/taylor_index.css">
cwcox commented

Just switched it up to match the above and everything works great. Thanks!

cwcox commented

Now the stylesheets load, but none of my components do! They load to the browser but aren't put into the view. I have update the repo

cwcox commented

never mind, it was hidden under the header.