Skip to content
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

manifest.json <link hrefs> turn into [object Object] #558

Closed
jonikorpi opened this issue Sep 3, 2016 · 14 comments
Closed

manifest.json <link hrefs> turn into [object Object] #558

jonikorpi opened this issue Sep 3, 2016 · 14 comments
Milestone

Comments

@jonikorpi
Copy link

(Using 0.4.0)

If I add this:
<link rel="manifest" href="./src/manifest.json">

It turns into this in dev:
<link rel="manifest" href="[object Object]">

And into this after build:
<link rel="manifest" href="[object" object]="">

(Found a few issues talking about serving manifest.json but nothing that specifically mentions this happening.)

@gaearon
Copy link
Contributor

gaearon commented Sep 3, 2016

This happens because for JSON, we use json-loader (which gives you an object).

We can definitely treat manifest.json specially by convention. To do this, you can send a PR matching that exact name, and using file-loader instead of json-loader. We already have special handling for favicon.ico so you can look at it for inspiration. This entry would need to go before the json-loader in the config for this to work.

We would need to place it outside src directory because it will be impossible to import it from code (you would start getting a file string). I think hardcoding top-level manifest.json to be treated like this is fine.

@gaearon gaearon added this to the 1.0.0 milestone Sep 3, 2016
@gaearon
Copy link
Contributor

gaearon commented Sep 3, 2016

cc @andreypopp @mxstbr

@jvorcak
Copy link

jvorcak commented Sep 3, 2016

@gaearon I want to start contributing and I'm looking for a first bug to start with now that I have more time. I could take this one.

@gaearon
Copy link
Contributor

gaearon commented Sep 3, 2016

Sounds great, @jvorcak you have it!
I will be away on a vacation but @mxstbr or @eanplatter might be able to review your PR.

@gaearon
Copy link
Contributor

gaearon commented Sep 3, 2016

#428 shows a similar approach where we handle a specific filename differently.

jvorcak added a commit to jvorcak/create-react-app that referenced this issue Sep 3, 2016
@gaearon gaearon mentioned this issue Sep 3, 2016
@andreypopp
Copy link
Contributor

Would be nice to find a way to configure html-webpack-compiler's loaders separately. That way we don't have confusing special cases added to main config (what if one would want to require the same resource both from index.html template and app code?). Also probably the only loader needed for html-webpack-plugin's compiler is `file-loader, right?

@jvorcak
Copy link

jvorcak commented Sep 5, 2016

@andreypopp I totally agree with that. I've spent some time investigating how that could be done and I got nowhere. There will be other files (apple icons, etc) that will be treated in a same way so I think more general solution needs to be proposed. I'll investigate whether html-webpack-compiler doesn't allow something like this.

@cmmartin
Copy link

cmmartin commented Sep 5, 2016

Why add special rules to the config for everyone's obscure use cases when you can just use the inline loader syntax in your application?

require('file?name=manifest.json!./path/to/manifest.json');

@GillesDebunne
Copy link

I have a related problem when trying to fully implement a favicon for my site. I'm following the recommandations from http://realfavicongenerator.net, which aim at providing a nice site icon for browsers, but also when the web site is pinned on a mobile home screen (for PWA).

Using <link rel="icon" href="./src/path/icon.png">, one can easily define a custom favicon for desktop and iOS.

Android however relies on the manifest file referenced in this issue. This file itself needs to reference a relative path to the Android home screen icon. Ideally, webpack should add this icon in the build folder, and its path should be updated in the manifest file.

Finally, IE/Edge relies on a browserconfig.xml file located at the root of the web site, which references the MS tile site's icon, in a way similar to the manifest above.

Check the RFG FAQ for details.

@gaearon
Copy link
Contributor

gaearon commented Sep 13, 2016

Why add special rules to the config for everyone's obscure use cases when you can just use the inline loader syntax in your application?

Because we don’t support this syntax officially. Webpack’s inline loader notation has proven to be extremely confusing to many developers, and is incompatible with other bundlers, locking your code into using Webpack.

We may stop supporting it at any moment so please don’t use it.

@gaearon gaearon modified the milestones: 0.4.2, 1.0.0, 0.5.0 Sep 13, 2016
@gaearon
Copy link
Contributor

gaearon commented Sep 18, 2016

Going to move this to 0.5.0 where I want to solve a few issues like this in a single batch.

@gaearon
Copy link
Contributor

gaearon commented Sep 22, 2016

I drafted a proposal to solve this in #703. Unless we find some fatal flaws, it should come out in 0.5.0. Let me know what you think!

@gaearon
Copy link
Contributor

gaearon commented Sep 22, 2016

Closing as this is fixed, and will be released in 0.5.0.

@gaearon gaearon closed this as completed Sep 22, 2016
@gaearon
Copy link
Contributor

gaearon commented Sep 23, 2016

This is now supported in 0.5.0.

Read about using the new public folder.

See also migration instructions and breaking changes in 0.5.0.

@lock lock bot locked and limited conversation to collaborators Jan 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants