Skip to content

Static assets relative path #433

@maxflex

Description

@maxflex

Let's say I put an image in /static/img.png and then reference it somewhere in css like so

.wrapper {
  background: url('/static/img.png')
}

It works fine. But when deployed to non-first-level url the app is referencing assets from root.

Thus, if I were to deploy to https://example.com/app-name/, the app would be referencing https://example.com/static/img.png instead of https://example.com/app-name/static/img.png (with /app-name).

If I don't go from root in CSS background: url('static/img.png') (fronting slash removed) webpack will interpret it as a module dependency.

How do I solve this?

*vue-cli webpack 2 template

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions