Skip to content

CSS: resolve relative paths without ./ prefix #469

@simon04

Description

@simon04

CSS url() defines:

Relative URLs, if used, are relative to the URL of the stylesheet (not to the URL of the web page).

Currently,. esbuild fails when encountering relative URLs without a ./ prefix:

$ npm install leaflet; echo 'require("leaflet/dist/leaflet.css")' | esbuild --bundle 

node_modules/leaflet/dist/leaflet.css:351:23: error: Could not resolve "images/layers.png" (mark it as external to exclude it from the bundle)
  background-image: url(images/layers.png);
                        ~~~~~~~~~~~~~~~~~
node_modules/leaflet/dist/leaflet.css:356:23: error: Could not resolve "images/layers-2x.png" (mark it as external to exclude it from the bundle)
  background-image: url(images/layers-2x.png);
                        ~~~~~~~~~~~~~~~~~~~~
node_modules/leaflet/dist/leaflet.css:397:23: error: Could not resolve "images/marker-icon.png" (mark it as external to exclude it from the bundle)
  background-image: url(images/marker-icon.png);
                        ~~~~~~~~~~~~~~~~~~~~~~
<stdin>:1:8: error: Cannot import "node_modules/leaflet/dist/leaflet.css" into a JavaScript file without an output path configured
require("leaflet/dist/leaflet.css")
        ~~~~~~~~~~~~~~~~~~~~~~~~~~
4 errors

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions