Skip to content

Commit

Permalink
chore(ionic-test-app): prevent copy complete theme project
Browse files Browse the repository at this point in the history
  • Loading branch information
danielleroux committed Nov 26, 2024
1 parent 9cef8f7 commit 925c48f
Showing 1 changed file with 22 additions and 18 deletions.
40 changes: 22 additions & 18 deletions packages/ionic-test-app/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()],
Expand Down

0 comments on commit 925c48f

Please sign in to comment.