Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Having issues with `copy` and relative path to `to`

Open
#143 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
30/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
javascript
Domain
build-system

Research direction

Start by reproducing the reported Rollup configuration with postcss-url, including the relative to, extract, and assetsPath values, and inspect how the copied asset path is generated. Done means the image remains in public/dist and the generated CSS references it as /dist/<hash>.jpg or a same-directory relative path.

Written by the indexing model from the issue text.

Description

Hey so I have the following config (in rollup):

postcss({
    to: './public/dist/',
    extract: 'public/dist/app.css',
    plugins: [
        url({
            url: 'copy',
            useHash: true,
            assetsPath: './dist/',
        })
    ]
})

And the following CSS:

.hero {
    background-image: url("../images/hero.jpg");
}

Which is the closest I can get it to working, the image is in the right directory public/dist however the CSS path is background-image: url("dist/7d8c51c4.jpg");

This resolves to http://localhost/dist/dist/7d8c51c4.jpg as opposed to http://localhost/dist/7d8c51c4.jpg.

I am running a server in the public/ directory and essentially need the path to be /dist/7d8c51c4.jpg or alternatively ./7d8c51c4.jpg as the image is in the same root as the generated CSS file.

I have tried every possible variation I can think of with the to and assetPath arguments, but I either get the path right and the image in the wrong directory or the image in the right directory and the wrong path.

Cheers.

Dominant language
JavaScript
Stars
383
Forks
58
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

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.

More from postcss/postcss-url

All issues in postcss/postcss-url

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.