-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
--no-content-hash or something else ? (don't touch the assets please) #3657
Comments
That's the problem for me too. I want to not hash images referenced in CSS because I am trying to not change some old project, just rebuild CSS in-place with Parcel. Now I got structure like this:
and I want to make it like this:
but Parcel fails on compiling it because
But do not want to change URLs in Maybe we can configure or disable this feature in Parcel? I found Also I found this comment in #1186 but commenting out all And finally, I found a plugin that monkey-patches original Parcel code, so we can find a workaround on how to disable assets copying: In sources, there is following thing: const Bundle = require('parcel-bundler/src/Bundle');
module.exports = function (bundler) {
Object.assign(Bundle.prototype, {
// here you can re-define methods from node_modules/parcel-bundler/src/Bundle.js
});
};
So, I copied |
i will just get Gulp for now |
As I needed this for some electron builds and others here is my tip. Or second option, you add the CSS lines with a bash or node script after parcel processed. No the best tho but still effective. |
also this issue is not a |
The doc mention this so it's an issue as this does nothing so far ^^ |
Yeah it's a big pain in the ass for those who do custom stuff by hand and not the mainthread techs :p But you can find different loaders for differents things, also what I've done to one of my project I build with Electron (and parcel just DIE if I put the script in reference LOL) it's to load custom files with a JS script, adding the tag in the DOM will do the job you are looking for, but in some cases you might need an extra script in your package to build those "detached" files. Waiting for parcel2 should resolve A LOT of those problems (hopefully !) |
This problem is frustrating me since parcel 1 and still in parcel 2. But dont worry. You can create a npm package which MUST begin with "parcel-namer-" and add it to a config. |
Parcel is essentially unusable for Shopify projects. Guess I'm going to use webpack then. 👍 This issue. |
I have a (temporary) workaround... I wrote a Node script to remove the hash from Parcel-bundled SVG sprites, so I can reference the sprites directly in the HTML or from JS-generated markup in components like sliders & accordions. Our production build & deploy process manages versioning of static assets (CSS/JS, and SVG) so I don't need to retain any hashes that Parcel generates. |
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. |
Also |
Thanks... but I'm not sure what you mean by I've looked at the docs for namer plugins... sorry, but I still don't understand how to author one and use it? Can an example be added to namers folder? |
This line ultimately adds the hash: https://v2.parceljs.org/plugin-system/namer#including-a-hash So removing this line would never add a hash:
But one problem is that you still need to generate a unique name for each bundle (which is rather difficult without using hashes for shared bundles). |
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.
Here avatar is the relative path passed to the function. |
❔ 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 sayunknown 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
The text was updated successfully, but these errors were encountered: