Skip to content

Multiple images with same name #246

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

Closed
graille opened this issue Jan 24, 2018 · 4 comments
Closed

Multiple images with same name #246

graille opened this issue Jan 24, 2018 · 4 comments
Labels
Bug Bug Fix Status: Waiting Feedback Needs feedback from the author

Comments

@graille
Copy link

graille commented Jan 24, 2018

Hi,

I've found an issue with Encore's image management when files have the same name
My assets/images folder loke like this :

.
├── backgrounds
│   ├── bg-1.jpg
├── bg-1.png

In my app.js, I call each static images used by my project (in JS or CSS files) one by one (@images is a webpack alias):

    // Images
    require('@images/logo.png')
    require('@images/backgrounds/bg-2.png')
    require('@images/bg-2.png')

(The problem is the same if files are referenced in a CSS file and not in a JS file)
But at the end, each images are moved in public/build/images directory :

.
├── app.8953b1aef7032187ce84.js
├── images
│   ├── bg-2.4972df67.png
│   ├── bg-2.68831990.png
│   └── logo.4972df67.png
└── manifest.json

But the manifest.json does not reference the two images :

{
  "build/app.js": "/build/app.8953b1aef7032187ce84.js",
  "build/images/bg-2.png": "/build/images/bg-2.4972df67.png",
  "build/images/logo.png": "/build/images/logo.4972df67.png"
}

Idea :
Would it not be better to have the same file tree in the public/build/images directory ? Something like this :

.
├── app.vue.8953b1aef7032187ce84.js
├── images
│   ├── backgrounds
│   │   └── bg-2.4972df67.png
│   ├── bg-2.68831990.png
│   └── logo.4972df67.png
├── manifest.json
@Lyrkan Lyrkan added the Bug Bug Fix label Jan 24, 2018
@Lyrkan
Copy link
Collaborator

Lyrkan commented Jan 24, 2018

Hey @graille,

That's indeed an issue due to the way the manifest.json file works.

We already discussed about that kind of thing before due to another issue that was a bit worse since the files would use the same name (no hash) and would end up overwriting each other:

TL;DR:

I'm still not sure about what we should do about that (ping @weaverryan) but in the meantime if you want to keep the same tree you can force the use of the [path] placeholder by calling configureFilenames:

Encore.configureFilenames({
    images: '[path][name].[hash:8].[ext]',
    fonts: '[path][name].[hash:8].[ext]'
});

@mikemix
Copy link

mikemix commented Jan 31, 2019

Still open :(

@Kocal
Copy link
Member

Kocal commented Jan 25, 2025

Hi, @graille and @mikemix, is this issue still happening in 2025? With latest webpack and Encore versions?

@Kocal Kocal added the Status: Waiting Feedback Needs feedback from the author label Jan 25, 2025
@mikemix
Copy link

mikemix commented Jan 26, 2025

Hi @Kocal. AFAIR it does not.

@Kocal Kocal closed this as completed Feb 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Bug Fix Status: Waiting Feedback Needs feedback from the author
Projects
None yet
Development

No branches or pull requests

4 participants