-
-
Notifications
You must be signed in to change notification settings - Fork 200
Consider reverting #110 #136
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
Comments
Hi @jderusse, A bit of context about why we did that change: with the old behavior if you had two file with the same name in different subfolders (e.g. Is there really a case where having a hash in the filename would cause an issue? Which problem would you have with a favicon for instance? About considering alternatives:
Note that for very specific cases you can also require your images using the |
Yo @jderusse! I'm open to reverting if that's the right choice. But I'm also curious about your setup: are you referencing // will be something like build/main.abc123.png
const imagePath = require('../images/main.png'); In other words, you shouldn't care about the final filename. And that's why we're curious about your setup :). Cheers! |
Thank you for your feedback. Actually, I don't care about the file path for a developer point of view. We both agree on that point :-) But as soon as I expose a path to my users this path belong to the legacy and have to be maintained. You never known when this file will be requested by the user. You could answer that as long as the file doesn't change, the file path will remain the same and it'll work and so, if the path change, it means that the file is not the same and the user will retrieve an unexpected image. I would answer. Yes your right. But I prefer to provide the wrong asset than nothing (because most of the time the image with the same is really near of the previous one). The only solution is to keep the assets forever. (In a CDN for instance) but it required to change a lot of thing in the infrastructure and the way we build the assets and served assets. So my point is, if I choose to not use the versionning. Please, don't version files :-) Configuring naming strategy (and EnableVersionning() as a shortcut) sound to be a good compromise. Thank you for your time (I really like this Component). I would be happy to write PRs and help. |
I see your point but I don't totally agree with it. A solution to your problem could be to keep old files between deployments. You don't need a CDN in order to do that: deploying the new build on top of the old one should do the job. That way, if an user tries to access to an old version of a file he'll retrieve it instead of the new one which could be entirely different and break your layout, email, etc. In my opinion the old behavior ( |
With automate build (like docker) in a CI, keeping build files between build is not a easy thing. I don't says that my point is more important or common than the dupplicate name issue. Indeed, #125 could be a workarround. And why not extending Enable/DisableVersionning ?
|
Don't get me wrong I'm not saying that we made the right choice with this commit, I simply wanted to point out that if we do revert it we also need to do something else at the same time to prevent the old issue from coming back :)
True, but that also means that you'll have the same issue if you delete or move one of your assets (if we switch to
One downside I see with this approach is that calling Defaults configurations could be: With versioning
Without versioning
|
Sounds good to me :) |
yeah, this one is also rather important for us. Let me quickly describe the scenario. We're on Symfony2.8 and using the Long story short: we're desperately waiting for this pr! 😄 |
Thanks for sharing you use-case :). I have just one question: are you manually requiring the loading.gif from some .js file just so that Webpack will move it into the build/ directory? I'm asking because the correct solution might be to use the copy-webpack-plugin... since this asset is not really handled by Webpack. But there could be more to your situation - that's why I'm asking :). Cheers! |
… (Lyrkan) This PR was merged into the master branch. Discussion ---------- Add Encore.configureFilenames() method to the public API This PR adds the `Encore.configureFilenames()` method to the public API (fixes #125). **Example:** ```js Encore.configureFilenames({ js: '[name].[chunkhash].js', css: '[name].[contenthash].css', images: 'images/[name].[hash:8].[ext]', fonts: 'fonts/[name].[hash:8].[ext]' }); ``` If one key is defined in the first parameter it will be used for the filenames of the related category. If it isn't the behavior will stay the same as before. For now I kept the old naming strategies as the default values. We could eventually change that following the discussion in #136. Commits ------- 0c9a8fe Add Encore.configureFilenames() method to the public API
It's actually worse :D In the bad old assetic times we had an assetic config that copied some image assets from (bower-) libraries to our web/images folder, leaving all names intact (so if we didn't watch and had assets with the same target name they would've overwritten each other). after introducing encore/webpack we're requiring a library that comes with a loading.gif and references it somewhere in its assets. Webpack therefore picks it up and copies it to our image folder; When leaving the "enableVersioning" flag off, in 0.12 the image's name is simply kept ("loading.gif"), from 0.13 on it was rewritten. We're not requiring that file in our own js files but it's imported implicitly by that library. We're actually using the copy-webpack-plugin to copy over most of our base assets into our build folder - that actually helped solving my situation for now: I just put a copy of that loading.gif in our source folder so it's copied (same behaviour as before) and I can simply continue to use the asset helper. As said: if we were using Symfony 3.3 and its manifest based asset versioning scheme the asset helper should've been able to pick up the right file when consulting manifest.json. But not so on 2.8 ;) |
Hm. This seems to have been solved more or less In 0.14. But now I have a weird issue. My settings:
When I when I
|
Indeed, that's really odd, filenames shouldn't change unless you call I can't seem to reproduce the issue on my side though, would you mind sharing your |
Ah, guys, sorry, 🍺 on me: I had two encore watch procs running in the same dir at the same time (one survived a terminal kill and went on watching with the old config) 🙄 |
No problem, glad you solved your issue :) |
I agree that #110 should be reverted. I understand the problem that it solves, but it seems like a nasty, undocumented hack to me. If I pass |
Hi @andyexeter, Could you describe an use case in which having the hash included in images/fonts filenames would be an issue? The naming strategy wasn't changed because of a bug, it was doing exactly what it was told to do before but that could lead to problems in very common cases:
In my opinion If you really want to remove the hash (or use something like |
Hey @Lyrkan, There are a few different use cases I can think of including SEO and link sharing but to be honest the use case is kind of irrelevant - the point I'm trying to make is that the hash being added to the images is undocumented, and unexpected when versioning has been explicitly disabled. I wasted a fair bit of time thinking there was something wrong with my config and was only able to find out the cause of this by reading through the project's issues. Is it not a strong enough argument to say I just don't want hashes appended to my filenames? I don't care about cache-busting (even though this isn't being done to bust caches) - I want my pretty filenames (I'm speaking hypothetically here). Just because something works, it doesn't mean it's the right thing to do. It'd still work if every single file processed by webpack was renamed 'doge1.js', 'wow_many_image.jpg', 'such_css.css' etc but that doesn't mean it should be done 😄 It just seems like putting a plaster/band-aid on a bug and forgetting about it. Instead, I believe we should be discussing why we can't have files with the same name in a different directory. If it's a problem with a loader or another of the project's dependencies I'd happily open an issue about it there. If I have |
I do think that use-cases are relevant since you shouldn't have to worry about filenames if there was no use-case requiring them to stay the same.
As I said in my previous reply you can now do that using
The previous behavior was to use
We talked about it in #103 and the only other viable alternative was to use |
This doesn't change the fact that there's no documentation saying Reading between the lines, I now understand the problem is because the directory structure isn't kept when moving files to the build directory, hence the potential for filename conflicts. In my opinion, Thanks for the information. I'll use |
Let's add a note to the docs (and maybe also the jsdoc?) about the |
With the encore symfony4 becomes messy. So many extra files downloaded to project, creates bad impression. Using external tools(or manually) to compress and minify and to a single file is easy i think. There is no simplicity |
@featuriz webpack-encore is meant to simplify the usage of webpack. If you just want to concatenate some files together and access external libraries through global variables (i.e. the old way of writing JS), you don't need webpack at all (and so you don't need encore). You could just use |
Closing - issue is old. Please open a new issue if needed! Thanks! |
Versionning may be disabled at the user choice. Encore shouldn't ignore this choice to fix a technical naming issue.
For the final user, getting the bad file, may be better than no file at all (think about favicon.ico for instance). And IMO it shouldn't be a choice made be encore for you.
Please consider other alternatives like using the
[path]
when versioning is disabled or using a hash based on the filepath instead of the file contentThe text was updated successfully, but these errors were encountered: