Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support public prefix on copy #173

Open
fgnass opened this issue May 18, 2022 · 2 comments
Open

Support public prefix on copy #173

fgnass opened this issue May 18, 2022 · 2 comments

Comments

@fgnass
Copy link

fgnass commented May 18, 2022

I want to use postcss-url in a Remix project. The general setup is described in their docs with a directory layout that looks like this:

styles/
  app.css <-- the source file
app/
  styles/
    app.css <-- where postcss puts the processed file
  root.tsx <-- contains import "./styles/app.css", Remix will copy it to /public/build
/public
  build/
    _assets/
      app-${hash}.css <-- this is where Remix copies the imported file

In order to also hash the assets within the stylesheet, I'd like to place them right next to the source CSS and let postcss-url copy them to /build/assets while the processed CSS should still go to /app/styles/app.css so that Remix can pick it up.

Since Remix doesn't know anything about the assets and postcss does not know that Remix will finally move the processed file to /public/build/_assets/app-${hash}.css the URLs in the generated stylesheet don't match as they would point to url("../../public/assets/...").

I would suggest adding an option to specify a publicPrefix that could be set to /assets in this case. If specified, copy.js would not use path.relative(targetDir, newAssetPath) but normalize(path.join(publicPrefix, assetRelativePath))instead.

Please let me know if this sounds like a good idea to you and if you'd accept a PR for this feature.

@fkrauthan
Copy link

I would love something like that. Looking exactly for this at the moment.

@MrFox131
Copy link

+1. Not so hard to implement but very useful

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants