#Having trouble referencing css file

1 messages · Page 1 of 1 (latest)

obsidian wigeon
#

I'm having trouble referencing a css file.

I seem to have to put it in public/styles/global.css for it to build properly (i'm deploying on netlify).

However I can't reference it with <link rel="stylesheet" href="./styles/global.css">. It only works on npm dev run for me on <link rel="stylesheet" href="./public/styles/global.css">

What I find strange is I can reference images placed in public/assets/img1.png perfectly fine with "./assets/images/img1.png".

I need a little help here please, thanks!

The github repo is https://github.com/cheeyung/film-pre-launch

GitHub

Contribute to cheeyung/film-pre-launch development by creating an account on GitHub.

lost torrent
#

Hi! You can actually import style sheets similar to ESM modules I'm Astro. Just do the following in your root layout:

import 'relative/path/to/styles.css'

This also means you don't have to have your styles in the public folder.

See: https://docs.astro.build/en/guides/styling/#import-a-local-stylesheet

Docs

Learn how to style components in Astro with scoped styles, external CSS, and tooling like Sass and PostCSS.

obsidian wigeon
#

Thanks that worked perfectly!