-
-
Notifications
You must be signed in to change notification settings - Fork 27k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Load favicon through html-loader. #428
Conversation
@@ -3,6 +3,7 @@ | |||
<head> | |||
<meta charset="utf-8"> | |||
<meta name="viewport" content="width=device-width, initial-scale=1"> | |||
<link rel="shortcut icon" href="${require('./src/favicon.ico')}"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
webpack-ism
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a way to make html-loader work just on <link href="./src/favicon.js">
but I don't know how.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to find it :P
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure? require("./src/favicon.js")
seems less magical and also consistent with other webpack-isms used (require("./index.css")
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's just a weird thing to explain. Imports are natural in JS but odd in HTML. Also since we use ES6 some people won't even know what require
is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK
Also, I don't have any idea how all of this works... Seems like html-webpack-plugin runs html through |
test: /\.html/, | ||
loader: 'html', | ||
query: { | ||
attrs: ['link:href'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be extended with other tag:attribute
combinations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oooh nice. Can you think up any other common combinations?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't bother adding more at the moment but rather serve on per-request basis.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think img:src
is out of scope.
👍 Nice job |
As you already have @andreypopp Why you didn't do that? |
@just-boris This was exactly how it worked before. The intention here is not to solve the favico case but solve the generic problem of “how do I reference image (or other) files from |
* Disable contentBase in development * Document #428
* Load favicon through html-loader. Fixes facebook#291. * Add test for *.ico in e2e test suite * Configure html-loader to process <link href="..."> * Address feedback on html-loader inclusion. * Place favicon.ico at the root of the build dir * Make comment style consistent between prod and dev webpack configs * Fix html-loader config in dev mode
* Disable contentBase in development * Document facebook#428
* Load favicon through html-loader. Fixes facebook#291. * Add test for *.ico in e2e test suite * Configure html-loader to process <link href="..."> * Address feedback on html-loader inclusion. * Place favicon.ico at the root of the build dir * Make comment style consistent between prod and dev webpack configs * Fix html-loader config in dev mode
* Disable contentBase in development * Document facebook#428
Migration Instructions
Now
favicon.ico
is not treated specially anymore.If you use it, move it to
src
and add the following line to<head>
in your HTML:Use html-loader to load favicon.
Test plan:
Fixes #291.