-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
Load favicon through html-loader. #428
Changes from all commits
9c21c40
50fce72
edef7d3
22b175d
f35f725
58232c5
38f668b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -126,23 +126,33 @@ module.exports = { | |
loader: ExtractTextPlugin.extract('style', 'css?-autoprefixer!postcss') | ||
// Note: this won't work without `new ExtractTextPlugin()` in `plugins`. | ||
}, | ||
// JSON is not enabled by default in Webpack but both Node and Browserify | ||
// allow it implicitly so we also enable it. | ||
{ | ||
// JSON is not enabled by default in Webpack but both Node and Browserify | ||
// allow it implicitly so we also enable it. | ||
test: /\.json$/, | ||
include: [paths.appSrc, paths.appNodeModules], | ||
loader: 'json' | ||
}, | ||
// "file" loader makes sure those assets end up in the `build` folder. | ||
// When you `import` an asset, you get its filename. | ||
{ | ||
// "file" loader makes sure those assets end up in the `build` folder. | ||
// When you `import` an asset, you get its filename. | ||
test: /\.(jpg|png|gif|eot|svg|ttf|woff|woff2)(\?.*)?$/, | ||
test: /\.(ico|jpg|png|gif|eot|svg|ttf|woff|woff2)(\?.*)?$/, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ideally We could declare a loader entry specifically for it with hardcoded There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
It does! |
||
exclude: /\/favicon.ico$/, | ||
include: [paths.appSrc, paths.appNodeModules], | ||
loader: 'file', | ||
query: { | ||
name: 'static/media/[name].[hash:8].[ext]' | ||
} | ||
}, | ||
// A special case for favicon.ico to place it into build root directory. | ||
{ | ||
test: /\/favicon.ico$/, | ||
include: [paths.appSrc], | ||
loader: 'file', | ||
query: { | ||
name: 'favicon.ico?[hash:8]' | ||
} | ||
}, | ||
// "url" loader works just like "file" loader but it also embeds | ||
// assets smaller than specified size as data URLs to avoid requests. | ||
{ | ||
|
@@ -153,6 +163,15 @@ module.exports = { | |
limit: 10000, | ||
name: 'static/media/[name].[hash:8].[ext]' | ||
} | ||
}, | ||
// "html" loader is used to process template page (index.html) to resolve | ||
// resources linked with <link href="./relative/path"> HTML tags. | ||
{ | ||
test: /\.html$/, | ||
loader: 'html', | ||
query: { | ||
attrs: ['link:href'], | ||
} | ||
} | ||
] | ||
}, | ||
|
@@ -181,7 +200,6 @@ module.exports = { | |
new HtmlWebpackPlugin({ | ||
inject: true, | ||
template: paths.appHtml, | ||
favicon: paths.appFavicon, | ||
minify: { | ||
removeComments: true, | ||
collapseWhitespace: true, | ||
|
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.