|
60 | 60 |
|
61 | 61 | async function loadThemeTokens(themeName, paletteName) { |
62 | 62 | try { |
63 | | - // Try multiple import paths to ensure compatibility across environments |
64 | | - let defaultTokens; |
65 | | - let theme; |
66 | | - |
67 | | - // Get the base URL from the current location |
68 | | - const baseUrl = window.location.origin; |
69 | | - |
70 | | - // First try the base URL path |
71 | | - try { |
72 | | - defaultTokens = await import(`${baseUrl}/dist/themes/${themeName}/default.tokens.js`); |
73 | | - theme = defaultTokens.defaultTheme; |
74 | | - } catch (baseUrlError) { |
75 | | - // Try relative dist path |
76 | | - try { |
77 | | - defaultTokens = await import(`../../../../../dist/themes/${themeName}/default.tokens.js`); |
78 | | - theme = defaultTokens.defaultTheme; |
79 | | - } catch (relativeDistError) { |
80 | | - // Try absolute dist path |
81 | | - try { |
82 | | - defaultTokens = await import(`/dist/themes/${themeName}/default.tokens.js`); |
83 | | - theme = defaultTokens.defaultTheme; |
84 | | - } catch (absoluteDistError) { |
85 | | - // All import attempts failed |
86 | | - } |
87 | | - } |
88 | | - } |
| 63 | + // Load theme tokens |
| 64 | + const defaultTokens = await import(`/themes/${themeName}/default.tokens.js`); |
| 65 | + let theme = defaultTokens.defaultTheme; |
89 | 66 |
|
90 | 67 | // If a specific palette is requested, modify the palette structure |
91 | 68 | // to set the enabled property to 'always' |
|
98 | 75 | window.Ionic.config = window.Ionic.config || {}; |
99 | 76 | window.Ionic.config.customTheme = theme; |
100 | 77 |
|
101 | | - // Re-apply the global theme with multiple fallback paths |
| 78 | + // Re-apply the global theme |
102 | 79 | if (window.Ionic.config.get && window.Ionic.config.set) { |
103 | | - const themeUtilsPaths = [ |
104 | | - `${baseUrl}/dist/themes/utils/theme.js`, |
105 | | - '../../../../../dist/themes/utils/theme.js', |
106 | | - '/dist/themes/utils/theme.js' |
107 | | - ]; |
108 | | - |
109 | | - for (const path of themeUtilsPaths) { |
110 | | - try { |
111 | | - const themeModule = await import(path); |
112 | | - themeModule.applyGlobalTheme(theme); |
113 | | - break; |
114 | | - } catch (error) { |
115 | | - // Continue to next path |
116 | | - } |
117 | | - } |
| 80 | + const themeModule = await import('/themes/utils/theme.js'); |
| 81 | + themeModule.applyGlobalTheme(theme); |
118 | 82 | } |
119 | 83 | } catch (error) { |
120 | | - console.warn(`Failed to load theme tokens for ${themeName}:`, error); |
| 84 | + console.error(`Failed to load theme tokens for ${themeName}:`, error); |
121 | 85 | } |
122 | 86 | } |
123 | 87 |
|
|
0 commit comments