Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Place favicon.ico at the root of the build dir
  • Loading branch information
andreypopp committed Aug 12, 2016
commit f35f7251ceb64e3c208b839da5188af011f36f86
10 changes: 10 additions & 0 deletions config/webpack.config.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,21 @@ module.exports = {
{
test: /\.(ico|jpg|png|gif|eot|svg|ttf|woff|woff2)(\?.*)?$/,
include: [paths.appSrc, paths.appNodeModules],
exclude: /\/favicon.ico$/,
loader: 'file',
query: {
name: 'static/media/[name].[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.
{
Expand Down
10 changes: 10 additions & 0 deletions config/webpack.config.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,22 @@ module.exports = {
// "file" loader makes sure those assets end up in the `build` folder.
// When you `import` an asset, you get its filename.
test: /\.(ico|jpg|png|gif|eot|svg|ttf|woff|woff2)(\?.*)?$/,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally favicon.ico specifically should end up in root build output folder so that browser see it even for files requested from the domain. (Not a big deal but still.)

We could declare a loader entry specifically for it with hardcoded name. However we would have to exclude hash from its name—otherwise it defeats the point. But then we don’t have a way to bump cache. I wonder if Webpack understands name: 'favicon.ico?[hash:8].

Copy link
Contributor Author

@andreypopp andreypopp Aug 12, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if Webpack understands name: 'favicon.ico?[hash:8]

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.
{
Expand Down
6 changes: 3 additions & 3 deletions tasks/e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ test -e build/*.html
test -e build/static/js/*.js
test -e build/static/css/*.css
test -e build/static/media/*.svg
test -e build/static/media/*.ico
test -e build/favicon.ico

# Run tests
npm run test
Expand Down Expand Up @@ -97,7 +97,7 @@ test -e build/*.html
test -e build/static/js/*.js
test -e build/static/css/*.css
test -e build/static/media/*.svg
test -e build/static/media/*.ico
test -e build/favicon.ico

# Run tests
npm run test
Expand All @@ -115,7 +115,7 @@ test -e build/*.html
test -e build/static/js/*.js
test -e build/static/css/*.css
test -e build/static/media/*.svg
test -e build/static/media/*.ico
test -e build/favicon.ico

# Run tests
npm run test
Expand Down