parcel-bundler / parcel-bundler/lightningcss

Wrong urls after bundling

Open
#181 7 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
7.7k
Forks
302
PR merge metrics
No merged PRs in 30d

Description

Hello, there is an issue relative to urls when parcel bundle css files together.
Urls found in files that gets bundled should be updated somehow because the following happens for now:

elements.css

@import "./fire/fire.css";
@import "./water/water.css";

fire/fire.css

.fire {
  background: url("./logo.png");
}

water/water.css

.water {
  background: url("./logo.png");
}

Actual output generated by parcel

.fire, .water {
  background: url(./logo.png);
}

Expected output

.fire {
  background: url(./fire/logo.png);
}
.water{
  background: url(./water/logo.png);
}
Code used to run parcel css bundler
import { createRequire } from "node:module"
import { fileURLToPath } from "node:url"

const require = createRequire(import.meta.url)

const { bundle } = require("@parcel/css")

const { code } = await bundle({
  filename: fileURLToPath(new URL("./elements.css", import.meta.url)),
  minify: false,
})
console.log(String(code))

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Run the provided @parcel/css bundle example with elements.css and the fire/water stylesheet structure to reproduce the incorrect URLs. Trace how CSS @import and url() paths are handled during bundling; done means the generated CSS preserves fire/logo.png and water/logo.png as separate relative paths.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, rust
Domain
build-system, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.