--no-content-hash or something else ? (don't touch the assets please)
See original GitHub issue❔ Question
Hello!
I’ve searched all along but I don’t see anything that really answer the question (or the problem).
I want to take benefit of the --no-content-hash
but the console say unknown option
–no-content-hash’` and I tried with the ‘build’ command and it make the (nearly) same output, files are still hashed.
I use the plugin parcel-plugin-asset-copier
Here are my full commands:
Dev: "dev:local": "cross-env parcel html/index-dev.html --no-autoinstall --port 8081 -d dist/dev/ --cert ssl/localhost.crt --key ssl/localhost.key",
Prod: "build": "cross-env parcel build --no-content-hash html/index-dev.html -d dist/prod/"
So far so good (without the --no-content-hash) but the problem is that every single assets used by html/css is hashed and throw in the dev/ folder, while I also have every assets in my /assets/ sub repos.
So I have fonts, icons, etc. And also got them in /assets/.
Maybe that something we will be able to do in Parcel 2? (I’m on LTS projects only…)
🔦 Context
I would like that parcel do not modify resources that way I can keep them in the folder. It’s not “clean” that way and we have several builds on the server using the same resources. Also, each templates (and JS) are using images, so I can’t just “delete” my assets folders, as it is now, parcel put some images in the dist/, and I have duplicates in assets/ and both are used…
🌍 Your Environment
Last parcel 1.12.4
parcel plugin asset copier: 1.0.0
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:14 (3 by maintainers)
You can solve this with a custom namer plugin: https://v2.parceljs.org/plugin-system/namer#content. This gives you complete control over the file naming of all bundles produced by parcel.
This has been a headache for almost 5 days. I’m trying to make a carousel of images using plain JS, but every time I run the code to change the image, Voila - the image doesn’t load. So I tried to console.log to check the URL of the original image (which is present locally in the assets folder), referenced in the index.html file, and there I see this hash being added to the name of the image file. Now I’m not sure whether Parcel adds the hash to the URL, after I change it in JS, because no matter how many times I check the image doesn’t get reference and it just doesn’t load.
<div class="avatar-container"> <img src="assets/avatar/avatar-1.jpg" alt="Picture of a person"> </div>
const setImage = (avatar, image) => { console.log('test🐸'); const avatarImage = avatarContainer.querySelector('img'); avatarImage.src = avatar; // console.log(avatarImage); }
Here avatar is the relative path passed to the function.