From 144117bf586e1306b8e7dc16c5fafdeec1301b8a Mon Sep 17 00:00:00 2001 From: Kat Date: Tue, 15 Aug 2023 09:41:09 +0200 Subject: [PATCH] fix(assets): import assets directly --- src/scripts/components/main/menu/menu.tsx | 4 +++- src/scripts/config/main.ts | 2 +- src/scripts/libs/download-screenshot.ts | 9 ++++----- vite.config.ts | 5 +++++ 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/scripts/components/main/menu/menu.tsx b/src/scripts/components/main/menu/menu.tsx index 615f64629..84736214b 100644 --- a/src/scripts/components/main/menu/menu.tsx +++ b/src/scripts/components/main/menu/menu.tsx @@ -1,6 +1,8 @@ import React, {FunctionComponent, useState} from 'react'; import {FormattedMessage} from 'react-intl'; +import planeratyVisionsLogo from '~/assets/images/planetary-visions.png'; + import LanguageSelector from '../language-selector/language-selector'; import Button from '../button/button'; import {PresenterIcon} from '../icons/presenter-icon'; @@ -199,7 +201,7 @@ const Menu: FunctionComponent = ({onRestartOnboarding}) => {

- + diff --git a/src/scripts/config/main.ts b/src/scripts/config/main.ts index 22aa014f0..d63174e12 100644 --- a/src/scripts/config/main.ts +++ b/src/scripts/config/main.ts @@ -117,7 +117,7 @@ export default { twitter: 'http://twitter.com/intent/tweet?text=ESA%20Climate%20From%20Space&url={currentUrl}' }, - planeratyVisionsLogo: 'assets/images/planetary-visions.png', + esaLogo: 'assets/images/esa-logo.png', ubilabsWebsite: 'https://ubilabs.com', planetaryVisionsWebsite: 'http://planetaryvisions.com/', diff --git a/src/scripts/libs/download-screenshot.ts b/src/scripts/libs/download-screenshot.ts index a564d3bef..be998e3b2 100644 --- a/src/scripts/libs/download-screenshot.ts +++ b/src/scripts/libs/download-screenshot.ts @@ -1,4 +1,5 @@ -import config from '../config/main'; +import esaLogoSrc from '~/assets/images/esa-logo.png'; + import {LayerListItem} from '../types/layer-list'; // Downloads one or both Cesium canvases as an image file @@ -10,9 +11,7 @@ export function downloadScreenshot( ) { const canvases = Array.from( // eslint-disable-next-line no-undef - document.querySelectorAll('.cesium-viewer canvas') as NodeListOf< - HTMLCanvasElement - > + document.querySelectorAll('.globe canvas') as NodeListOf ); const fileName = createFileName( @@ -50,7 +49,7 @@ export function downloadScreenshot( }; esaLogo.setAttribute('crossOrigin', 'anonymous'); - esaLogo.src = config.esaLogo; + esaLogo.src = esaLogoSrc; } function combineCanvases(canvases: HTMLCanvasElement[]) { diff --git a/vite.config.ts b/vite.config.ts index b7d21ef2d..333456cb8 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -21,6 +21,11 @@ export default defineConfig(({command}) => { return { root: './src', base: './', + resolve: { + alias: { + '~': __dirname + } + }, build: { outDir: '../dist', emptyOutDir: true,