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

Maryia/Loading favicons based on size & excluded them from service worker #5172

Merged
30 changes: 26 additions & 4 deletions packages/core/build/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const copyConfig = base => {
to: 'favicon.ico',
toType: 'file',
},
{ from: path.resolve(__dirname, '../src/public/images/favicons/'), to: 'public/images/favicons' },
{ from: path.resolve(__dirname, '../src/public/images/favicons/'), to: 'public/images/favicons/' },
{
from: path.resolve(__dirname, '../src/public/images/common/static_images/'),
to: 'public/images/common',
Expand Down Expand Up @@ -132,6 +132,8 @@ const generateSWConfig = is_release => ({
/sitemap\.xml$/,
/robots\.txt$/,
/manifest\.json$/,
/^public\/images\/favicons\//,
/^favicon\.ico$/,
/^apple-app-site-association/,
/^assetlinks.json/,
/^.well-known\//,
Expand Down Expand Up @@ -180,13 +182,33 @@ const htmlInjectConfig = () => ({
},
},
{
path: 'public/images/favicons',
glob: '*',
globPath: path.resolve(__dirname, '../src/public/images/favicons'),
path: 'favicon.ico',
attributes: {
rel: 'icon',
},
},
...[
{ name: 'favicon', rel: 'icon', size: '16' },
{ name: 'favicon', rel: 'icon', size: '32' },
{ name: 'favicon', rel: 'icon', size: '96' },
{ name: 'favicon', rel: 'icon', size: '160' },
{ name: 'favicon', rel: 'icon', size: '192' },
{ name: 'apple-touch-icon', size: '57' },
{ name: 'apple-touch-icon', size: '60' },
{ name: 'apple-touch-icon', size: '72' },
{ name: 'apple-touch-icon', size: '76' },
{ name: 'apple-touch-icon', size: '114' },
{ name: 'apple-touch-icon', size: '120' },
{ name: 'apple-touch-icon', size: '144' },
{ name: 'apple-touch-icon', size: '152' },
{ name: 'apple-touch-icon', size: '180' },
].map(({ name, rel, size }) => ({
path: `public/images/favicons/${name}-${size}.png`,
attributes: {
rel: rel || name,
sizes: `${size}x${size}`,
},
})),
],
append: false,
});
Expand Down
17 changes: 1 addition & 16 deletions packages/trader/build/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const { IS_RELEASE } = require('./constants');
const generateSWConfig = () => ({
importWorkboxFrom: 'local',
cleanupOutdatedCaches: true,
exclude: [/CNAME$/, /index\.html$/, /404\.html$/],
exclude: [/CNAME$/, /index\.html$/, /404\.html$/, /^public\/images\/favicons\//, /^favicon\.ico$/],
skipWaiting: true,
clientsClaim: true,
});
Expand All @@ -24,20 +24,6 @@ const htmlOutputConfig = () => ({
},
});

const htmlInjectConfig = () => ({
links: [
{
path: 'public/images/favicons',
glob: '*',
globPath: path.resolve(__dirname, '../src/public/images/favicons'),
attributes: {
rel: 'icon',
},
},
],
append: false,
});

const cssConfig = () => ({
filename: 'trader/css/trader.main.[contenthash].css',
chunkFilename: 'trader/css/trader.[name].[contenthash].css',
Expand All @@ -52,7 +38,6 @@ const stylelintConfig = () => ({

module.exports = {
htmlOutputConfig,
htmlInjectConfig,
cssConfig,
stylelintConfig,
generateSWConfig,
Expand Down