Skip to content

Commit

Permalink
Include icons/images in dist by importing them explicitly
Browse files Browse the repository at this point in the history
  • Loading branch information
arnellebalane committed Sep 24, 2023
1 parent 1c3b705 commit 9499f3b
Show file tree
Hide file tree
Showing 11 changed files with 91 additions and 24 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"start": "vite dev",
"dev": "netlify dev",
"build": "vite build",
"preview": "vite preview",
"lhci": "lhci autorun",
"prezip": "npm run build",
"zip": "./scripts/zip.sh"
Expand Down
9 changes: 6 additions & 3 deletions src/app/components/AppTopBar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { onMount, onDestroy } from 'svelte';
import { APP_VERSION } from '@lib/constants';
import { icons } from '@lib/icons';
import { enableShortcut, disableShortcut } from '@features/shortcuts';
import { settings } from '@features/settings/store';
import { changelogs, version } from '@features/changelogs/store';
Expand All @@ -15,6 +16,8 @@ import WhatsNewButton from '@features/changelogs/components/WhatsNewButton.svelt
import QuickLinks from '@features/quick-links/components/QuickLinks.svelte';
import FrequentLinks from '@features/quick-links/components/FrequentLinks.svelte';
import ChromeWebStoreImage from '@assets/images/chrome-webstore.png';
let settingsUnsubscribe = null;
let settingsFormData = {};
let showSettingsForm = false;
Expand Down Expand Up @@ -74,8 +77,8 @@ onDestroy(() => disableShortcut('togglePrivacyMode'));
<Button
icon
medium
iconLight="/src/assets/icons/settings-light.svg"
iconDark="/src/assets/icons/settings-dark.svg"
iconLight={icons.settingsLight}
iconDark={icons.settingsDark}
on:click={() => toggleSettingsForm(true)}
>
Settings
Expand All @@ -87,7 +90,7 @@ onDestroy(() => disableShortcut('togglePrivacyMode'));
rel="noopener noreferrer"
class="umami--click--chrome-webstore-link"
>
<img src="/src/assets/images/chrome-webstore.png" alt="Available in the Chrome Webstore" />
<img src={ChromeWebStoreImage} alt="Available in the Chrome Webstore" />
</a>
{/if}
</div>
Expand Down
16 changes: 10 additions & 6 deletions src/features/changelogs/components/WhatsNew.svelte
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
<script>
import { createEventDispatcher } from 'svelte';
import { changelogs, setVersionIfHigher } from '../store';
import { icons } from '@lib/icons';
import Button from '@components/Button.svelte';
import WhatsNewImageLight from '@assets/images/whats-new-empty-light.jpg';
import WhatsNewImageDark from '@assets/images/whats-new-empty-dark.jpg';
const dispatch = createEventDispatcher();
$: screens = [
...$changelogs,
{
title: `You're now up to date!`,
imageLight: '/src/assets/images/whats-new-empty-light.jpg',
imageDark: '/src/assets/images/whats-new-empty-dark.jpg',
imageLight: WhatsNewImageLight,
imageDark: WhatsNewImageDark,
},
];
Expand Down Expand Up @@ -43,8 +47,8 @@ const handleNext = () => (index = Math.min(index + 1, screens.length - 1));
<Button
icon
small
iconLight="/src/assets/icons/chevron-left-light.svg"
iconDark="/src/assets/icons/chevron-left-dark.svg"
iconLight={icons.chevronLeftLight}
iconDark={icons.chevronLeftDark}
class="PreviousButton"
on:click={handlePrevious}
>
Expand All @@ -62,8 +66,8 @@ const handleNext = () => (index = Math.min(index + 1, screens.length - 1));
<Button
icon
small
iconLight="/src/assets/icons/chevron-right-light.svg"
iconDark="/src/assets/icons/chevron-right-dark.svg"
iconLight={icons.chevronRightLight}
iconDark={icons.chevronRightDark}
class="NextButton"
on:click={handleNext}
>
Expand Down
5 changes: 3 additions & 2 deletions src/features/changelogs/components/WhatsNewButton.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script>
import { icons } from '@lib/icons';
import Button from '@components/Button.svelte';
export let pulse = false;
Expand All @@ -8,8 +9,8 @@ export let pulse = false;
<Button
icon
medium
iconLight="/src/assets/icons/launch-light.svg"
iconDark="/src/assets/icons/launch-dark.svg"
iconLight={icons.launchLight}
iconDark={icons.launchDark}
class="WhatsNewButton {pulse ? 'pulse' : ''}"
on:click
>
Expand Down
13 changes: 13 additions & 0 deletions src/features/quick-links/icons.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import gmail from '@assets/images/gmail.png';
import meet from '@assets/images/meet.png';
import drive from '@assets/images/drive.png';
import calendar from '@assets/images/calendar.png';
import photos from '@assets/images/photos.png';

export const icons = {
gmail,
meet,
drive,
calendar,
photos,
};
9 changes: 5 additions & 4 deletions src/features/quick-links/settings/CustomUrlItem.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { createEventDispatcher } from 'svelte';
import { SHADOW_ITEM_MARKER_PROPERTY_NAME } from 'svelte-dnd-action';
import { icons } from '@lib/icons';
import { confirmation } from '@app/stores/confirmation';
import Button from '@components/Button.svelte';
Expand Down Expand Up @@ -30,8 +31,8 @@ const handleRemove = async () => {
<Button
small
icon
iconLight="/src/assets/icons/drag.svg"
iconDark="/src/assets/icons/drag.svg"
iconLight={icons.drag}
iconDark={icons.drag}
class="CustomUrl_Action CustomUrl_Action-drag"
type="button"
tabindex="-1"
Expand All @@ -41,8 +42,8 @@ const handleRemove = async () => {
<Button
small
icon
iconLight="/src/assets/icons/delete.svg"
iconDark="/src/assets/icons/delete.svg"
iconLight={icons.remove}
iconDark={icons.remove}
class="CustomUrl_Action"
type="button"
on:click={handleRemove}
Expand Down
11 changes: 6 additions & 5 deletions src/features/quick-links/settings/QuickLinksSettings.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@ import { createEventDispatcher } from 'svelte';
import { getDefaultSettings } from '.';
import { frequentLinksSupported } from '../store';
import { icons } from '../icons';
import Switch from '@components/Switch.svelte';
import QuickLinksField from './QuickLinksField.svelte';
export let data = getDefaultSettings();
const builtInQuickLinks = [
{ title: 'Gmail', url: 'https://mail.google.com/', icon: '/src/assets/images/gmail.png' },
{ title: 'Meet', url: 'https://meet.google.com/', icon: '/src/assets/images/meet.png' },
{ title: 'Drive', url: 'https://drive.google.com/', icon: '/src/assets/images/drive.png' },
{ title: 'Calendar', url: 'https://calendar.google.com/', icon: '/src/assets/images/calendar.png' },
{ title: 'Photos', url: 'https://photos.google.com/', icon: '/src/assets/images/photos.png' },
{ title: 'Gmail', url: 'https://mail.google.com/', icon: icons.gmail },
{ title: 'Meet', url: 'https://meet.google.com/', icon: icons.meet },
{ title: 'Drive', url: 'https://drive.google.com/', icon: icons.drive },
{ title: 'Calendar', url: 'https://calendar.google.com/', icon: icons.calendar },
{ title: 'Photos', url: 'https://photos.google.com/', icon: icons.photos },
];
const dispatch = createEventDispatcher();
Expand Down
5 changes: 3 additions & 2 deletions src/features/search/components/SearchForm.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { onMount, onDestroy } from 'svelte';
import isEmpty from 'lodash/isEmpty';
import orderBy from 'lodash/orderBy';
import { icons } from '@lib/icons';
import { enableShortcut, disableShortcut } from '@features/shortcuts';
import { settings } from '@features/settings/store';
import { tags } from '@features/tags/store';
Expand Down Expand Up @@ -55,8 +56,8 @@ onDestroy(() => disableShortcut('focusSearch'));
icon
disabled={!hasSearchFilters}
data-tooltip="Clear search filters"
iconLight="/src/assets/icons/close-light.svg"
iconDark="/src/assets/icons/close-dark.svg"
iconLight={icons.closeLight}
iconDark={icons.closeDark}
type="button"
class="SearchClear"
on:click={search.clear}
Expand Down
5 changes: 3 additions & 2 deletions src/features/tags/settings/TagsSettings.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import isEmpty from 'lodash/isEmpty';
import orderBy from 'lodash/orderBy';
import { tags } from '../store';
import { icons } from '@lib/icons';
import Button from '@components/Button.svelte';
export let data = {};
Expand All @@ -25,8 +26,8 @@ const restoreTag = (tag) => {
<Button
medium
icon
iconLight={tag.removed ? '/src/assets/icons/restore.svg' : '/src/assets/icons/delete.svg'}
iconDark={tag.removed ? '/src/assets/icons/restore.svg' : '/src/assets/icons/delete.svg'}
iconLight={tag.removed ? icons.restore : icons.remove}
iconDark={tag.removed ? icons.restore : icons.remove}
type="button"
class="Button"
on:click={() => (tag.removed ? restoreTag(tag) : removeTag(tag))}
Expand Down
37 changes: 37 additions & 0 deletions src/lib/icons.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import chevronLeftDark from '@assets/icons/chevron-left-dark.svg';
import chevronLeftLight from '@assets/icons/chevron-left-light.svg';
import chevronRightDark from '@assets/icons/chevron-right-dark.svg';
import chevronRightLight from '@assets/icons/chevron-right-light.svg';
import closeDark from '@assets/icons/close-dark.svg';
import closeLight from '@assets/icons/close-light.svg';
import remove from '@assets/icons/delete.svg';
import dots from '@assets/icons/dots.svg';
import drag from '@assets/icons/drag.svg';
import edit from '@assets/icons/edit.svg';
import launchDark from '@assets/icons/launch-dark.svg';
import launchLight from '@assets/icons/launch-light.svg';
import refreshDark from '@assets/icons/refresh-dark.svg';
import refreshLight from '@assets/icons/refresh-light.svg';
import restore from '@assets/icons/restore.svg';
import settingsDark from '@assets/icons/settings-dark.svg';
import settingsLight from '@assets/icons/settings-light.svg';

export const icons = {
chevronLeftDark,
chevronLeftLight,
chevronRightDark,
chevronRightLight,
closeDark,
closeLight,
remove,
dots,
drag,
edit,
launchDark,
launchLight,
refreshDark,
refreshLight,
restore,
settingsDark,
settingsLight,
};
4 changes: 4 additions & 0 deletions vite.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ import { svelte } from '@sveltejs/vite-plugin-svelte';
export default defineConfig({
plugins: [svelte()],

build: {
assetsInlineLimit: 0,
},

resolve: {
alias: {
'@app': path.resolve(__dirname, 'src/app'),
Expand Down

0 comments on commit 9499f3b

Please sign in to comment.