let assetPath = this.addURLDependency(node.attrs[attr], {
from: 'html'
I'm not sure but thought there was a way to address the parent element already, i might be mistaken
With all the years of experience I've had thinking about these graph problems while implementing Assetgraph, I can tell you that you won't be able to infer from the asset alone what format you need to keep it in. Knowing the parent type will only be enough in the most naive cases as well. What you need is a model that also keep the information of what type of relation is between these two assets.
In Assegraph each way any asset can refer to a different asset is modelled as different relation type. This information has turned out to be much more valuable than the assets themselves, as you can infer a lot of things from the relation types alone. It's especially valuable when you start to traverse the graph for processing.
In this single case you might be able to hack it with a condition that excludes json files linked from html from being interpreted as js. But a bit further in the future you might want to cover the case where fetch('data.json')
is picked up as a file reference, and the application logic of runtime json loading would fail if the file changes extension as well.
You probably also want to start treating the webmanifest as a separate asset type inheriting from JSON, since it has well defined properties that also describe asset relations.
Just got here after some searching because I hit this very issue myself while trying to create a PWA with a manifest.json
file.
I think that in general, the most flexible thing from an HTML entry point would be to have some data attribute that we could use to manually tell Parcel.js NOT to process the file.
Something like this:
<link rel=“manifest” href="/src/manifest.json" data-parceljs-ignore>
That data attribute would then be noted, processing would be skipped for that file, and the resulting output would remove the data attribute without doing any processing on the file at all:
<link rel=“manifest” href="/src/manifest.json">
esaramago, akshaysmurthy, amir20, martingeorgiu, kcoyner, Tanoemon, judas-christ, msanatan, hanshou101, amazingandyyy, and 23 more reacted with thumbs up emoji
gonzaloriestra, raphaklaus, arturh85, lichenglu, amir20, martingeorgiu, tamlyn, kcoyner, Mindcraft1, sbward, and 14 more reacted with hooray emoji
All reactions
digitalbocca, keemor, cheeaun, lichenglu, krnlde, joseluisq, rjoydip-zz, MakChan, augnustin, viktordineout, and 16 more reacted with thumbs up emoji
aminnairi, raphaklaus, rrjoson, viktordineout, kcoyner, LifeOfQui, izn, lucasreppewelander, au5ton, nish17, and hanquf1 reacted with hooray emoji
hanquf1 and Alabs02 reacted with heart emoji
All reactions
This caused the PWA to open in a full browser on iOS
- Rename manifest.json to manifest.webmanifest (parcel-bundler/parcel#235 (comment))
- Include the new manifest file in index.html
@devongovett @DeMoorJasper hey! Just wanted to drop a quick note here for parcel v2. In talking to some friends at Google, it's important for how browsers handle web manifests specifically that the final filename stays the same between builds.
Otherwise it's interpreted as a different app, somehow. Maybe @slightlyoff or @addyosmani can elaborate a bit.
In order to work around this I've had to do some HTML manipulation after the fact to inject the manifest.
I just wanted to drop note in hopes that there would be some way to control the final filename in v2.
Thanks for all your work on Parcel! ❤️
Hey there. My use case is probably different: I've used create-react-app and now want to have a relatively easy (few mangling steps) way of bundling all assets with parcel--which BTW works awesome, not requiring to eject!
And I simply wanted to say it'd be great if there was a way to bundle/build with a tag/token of sorts that copies the original manifest.json file into the build folder (with that filename) and keeps the original content (link tag with rel="manifest" and href="/manifest.json" fields), even if in the original index.html file another tag (e.g. parcel-asset-copy-only) needed to be added, which I could do pre-build...
As a first pass, it's not too many steps:
https://github.com/neuroelf/dermodelphi/blob/master/README.md#building-with-parcel-without-minification
Anyway, great project!! :)
Given the discusison here: parcel-bundler/parcel#235
This needs to be done for parcel not to rename it as a json file
refs #82
How about putting manifest.json as an entry point? Then we know it shouldn't be renamed or converted to a module.
This is what I had in mind:
parcel src/manifest.json src/*.html src/*.js --hmr-hostname localhost
Parcel currently converts the manifest to a module even though it isn't referenced in any code.
* I later found the plugin for browser addons.
I was using the manifest.json
naming convention from the Google Web App Manifest documentation. While MDN was using the manifest.webmanifest
naming convention. Using the later solved the issue (which was Parcel.js converting the manifest.json
to a javascript file). Hope this helps!
This worked for me,
@GeoffMahugu is .webmanifest still working for you?
Yes it is, I have my index.html and manifest.webmanifest in src folder and this is how I reference the file in the index:
on running parcel src/index.html
should serve the manifest file.