lambda-packages icon indicating copy to clipboard operation
lambda-packages copied to clipboard

Config's `base` option producing unexpected asset paths

Open HappyTiptoe opened this issue 3 years ago • 4 comments

What version of astro are you using?

1.0.1

Are you using an SSR adapter? If so, which one?

None

What package manager are you using?

yarn

What operating system are you using?

Linux (Fedora 36)

Describe the Bug

At my company, we create websites for clients, and need to be able to host websites at paths which may change. By referencing assets via ./, this makes the website path agnostic, and doesn't require a rebuild should the path change.

Unfortunately, the base option in astro.config.mjs is not allowing for such a value, which is causing issues with asset/stylesheet referencing.

Config

Config

I have base set to "./" in my config file. With this, I expect <link>s, <script>s, and assets to be referenced via src="./path/to/file". However, I'm getting unexpected, inconsistent results.


import { defineConfig } from 'astro/config'

/* ... */

export default defineConfig({
  /* ... */
  base: './'
})

Results

Stylesheet

The stylesheet is referenced by /assets/..., which makes me feel that the base option isn't being respected at all here.

However, setting base: "/foo"will yield expected results. There seems to be an issue with the preceding ..


<link
  rel="stylesheet"
  href="/assets/index.be4ae9a2.css" 
/>

Assets

Whether in an Astro component, or a Vue component, my assets are referenced via src="/./assets/...".

Is the / is being prepended because the first character of the path isn't /, maybe?


<img src="/./assets/image.e23d31cb.jpg">

Link to Minimal Reproducible Example

https://github.com/ebxn/astro-repro

Participation

  • [ ] I am willing to submit a pull request for this issue.

HappyTiptoe avatar Aug 10 '22 08:08 HappyTiptoe