0

Does anyone know how I'll be able to import my external CSS and JS files into Astro's new version? I tried:

<link rel="stylesheet" href={Astro.resolve('../styles/style.css')}>

But it's not workings anymore after Astro's new 1.0 Update launch.

SukhOP
  • 1
  • 1
  • 2

2 Answers2

1

Astro.resolve has been deprecated as you can see in detail in the documentation.

Summary of the recommended ESM Import method:

  1. Place you .css file inside the src/ directory
  2. Import it in your .astro file:
---
// Example: Astro will include and optimize this CSS for you automatically
import './style.css';
---
<html><!-- Your page here --></html>
  1. Astro detects these CSS imports and then builds, optimizes, and adds the CSS to the page automatically.
Luca Pavan
  • 11
  • 1
0

If you place your style sheet in the public folder, you can simply import it using:

<link rel="stylesheet" href="index.css" />
Hasan Ali
  • 166
  • 1
  • 2
  • Minor correction: for public folder put /index.css However I am looking how to use Javascript which is kept in public folder as I am getting the following message: Please add the "is:inline" directive to keep this asset from being bundled. – Vijay Bhatter Sep 02 '22 at 10:58