diff --git a/packages/ionic-test-app/vite.config.ts b/packages/ionic-test-app/vite.config.ts index e4d399f56d..ee67b41732 100644 --- a/packages/ionic-test-app/vite.config.ts +++ b/packages/ionic-test-app/vite.config.ts @@ -6,34 +6,38 @@ import react from '@vitejs/plugin-react'; import { defineConfig } from 'vite'; import fs from 'fs-extra'; -async function copyOptionalThemeStyle() { - let style = ''; +function copyAdditionalThemeIfPresent() { try { - const themePackage = await import.meta.resolve('@siemens/ix-brand-theme'); - const theme = path.join(themePackage.replace('file://', ''), '..', '..'); - - fs.copySync( - theme, - path.join(__dirname, 'public', 'additional-theme', 'ix-brand-theme'), - { - filter: (src) => { - return !src.includes('node_modules'); - }, - } + const additionalTheme = import.meta.resolve('@siemens/ix-brand-theme'); + const basePath = path.join( + additionalTheme.replace('file://', ''), + '..', + '..' + ); + const targetPath = path.join( + __dirname, + 'public', + 'additional-theme', + 'ix-brand-theme' ); + const distPath = path.join(basePath, 'dist'); + const loaderPath = path.join(basePath, 'loader'); + + fs.ensureDirSync(targetPath); + + fs.copySync(distPath, path.join(targetPath, 'dist')); + fs.copySync(loaderPath, path.join(targetPath, 'loader')); return true; } catch (e) { - console.warn('Could not resolve ix-brand-theme package'); - console.error(e); + console.log('Skip injecting additional theme'); + return false; } - - return false; } // https://vitejs.dev/config/ export default defineConfig(async () => { - await copyOptionalThemeStyle(); + copyAdditionalThemeIfPresent(); return { base: './', plugins: [react(), legacy()],