Skip to content

Commit

Permalink
add svg favicon
Browse files Browse the repository at this point in the history
  • Loading branch information
vintikzzz committed Sep 29, 2024
1 parent acd28b8 commit 923241a
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 30 deletions.
1 change: 1 addition & 0 deletions templates/layouts/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<title>{{ template "title" . }} | Webtor.io</title>
<meta name="description" content="Download and play torrents with free online torrent web player and downloader. Just paste the magnet link or open the torrent file and start downloading or watching torrent content safely and anonymously through your web browser. Works instantly without client and registration!">
<link rel="shortcut icon" href="/assets/night/favicon.ico">
<link rel="icon" type="image/svg+xml" href="/assets/night/favicon.svg" >
<link rel="icon" type="image/png" sizes="16x16" href="/assets/night/favicon-16x16.png">
<link rel="icon" type="image/png" sizes="32x32" href="/assets/night/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="48x48" href="/assets/night/favicon-48x48.png">
Expand Down
67 changes: 37 additions & 30 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ const FaviconsWebpackPlugin = require('favicons-webpack-plugin');

const fs = require('fs');

const tailwindConfig = require('./tailwind.config');
const themes = tailwindConfig.daisyui.themes;

function getEntries(path, ext, prefix = '') {
return new Promise((resolve) => {
fs.readdir(path, { recursive: true }, (err, files) => {
Expand All @@ -19,28 +22,45 @@ function getEntries(path, ext, prefix = '') {
})
}

function makeFavicons(theme) {
return new FaviconsWebpackPlugin({
logo: `./assets/src/images/logo-${theme}.svg`,
prefix: `${theme}/`,
favicons: {
icons: {
android: false,
appleIcon: false,
appleStartup: false,
favicons: true,
windows: false,
yandex: false,
},
},
});
}

module.exports = async (env, options) => {
const jsEntries = await getEntries('./assets/src/js/app', '.js');
const styleEntries = await getEntries('./assets/src/styles', '.css');
const devMode = options.mode !== 'production';
const devEntries = devMode ? await getEntries('./assets/src/js/dev', '.js', 'dev/') : {};
const plugins = [
new MiniCssExtractPlugin({
filename: '[name].css',
}),
new CopyPlugin({
patterns: [
{ from: 'node_modules/mediaelement/build/mejs-controls.svg', to: 'mejs-controls.svg' },
{ from: 'node_modules/hls.js/dist/hls.min.js', to: 'lib/hls.min.js'},
{ from: 'node_modules/iframe-resizer/js/iframeResizer.contentWindow.min.js', to: 'lib/iframeResizer.contentWindow.min.js'},
],
}),
];
for (const t of themes) {
plugins.push(new FaviconsWebpackPlugin({
logo: `./assets/src/images/logo-${t}.svg`,
prefix: `${t}/`,
favicons: {
icons: {
android: false,
appleIcon: false,
appleStartup: false,
favicons: true,
windows: false,
yandex: false,
},
},
}));
plugins.push(new CopyPlugin({
patterns: [
{ from: `assets/src/images/logo-${t}.svg`, to: `${t}/favicon.svg` },
],
}));
}
return {
entry: {
...jsEntries,
Expand Down Expand Up @@ -108,19 +128,6 @@ module.exports = async (env, options) => {
},
]
},
plugins: [
new MiniCssExtractPlugin({
filename: '[name].css',
}),
new CopyPlugin({
patterns: [
{ from: 'node_modules/mediaelement/build/mejs-controls.svg', to: 'mejs-controls.svg' },
{ from: 'node_modules/hls.js/dist/hls.min.js', to: 'lib/hls.min.js'},
{ from: 'node_modules/iframe-resizer/js/iframeResizer.contentWindow.min.js', to: 'lib/iframeResizer.contentWindow.min.js'},
],
}),
makeFavicons('lofi'),
makeFavicons('night'),
],
plugins,
};
}

0 comments on commit 923241a

Please sign in to comment.