@gxp-dev/tools 2.0.38 → 2.0.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/runtime/vite.config.js +52 -0
- package/template/vite.config.js +38 -0
package/package.json
CHANGED
package/runtime/vite.config.js
CHANGED
|
@@ -205,6 +205,56 @@ export default defineConfig(({ mode }) => {
|
|
|
205
205
|
},
|
|
206
206
|
};
|
|
207
207
|
|
|
208
|
+
// Fallback plugin for missing @layouts files
|
|
209
|
+
// When a project doesn't have theme-layouts/, serve minimal fallbacks
|
|
210
|
+
// so PortalContainer.vue imports don't break
|
|
211
|
+
const layoutsDir = path.resolve(process.cwd(), "theme-layouts");
|
|
212
|
+
const layoutFallbackPlugin = {
|
|
213
|
+
name: "gxp-layout-fallback",
|
|
214
|
+
resolveId(source) {
|
|
215
|
+
// Only handle @layouts/ imports
|
|
216
|
+
if (!source.startsWith("@layouts/")) return null;
|
|
217
|
+
|
|
218
|
+
const fileName = source.replace("@layouts/", "");
|
|
219
|
+
const localFile = path.resolve(layoutsDir, fileName);
|
|
220
|
+
|
|
221
|
+
// If the file exists locally, let Vite resolve it normally
|
|
222
|
+
if (fs.existsSync(localFile)) return null;
|
|
223
|
+
|
|
224
|
+
// Return a virtual module ID for the missing file
|
|
225
|
+
return `\0gxp-layout-fallback:${fileName}`;
|
|
226
|
+
},
|
|
227
|
+
load(id) {
|
|
228
|
+
if (!id.startsWith("\0gxp-layout-fallback:")) return null;
|
|
229
|
+
|
|
230
|
+
const fileName = id.replace("\0gxp-layout-fallback:", "");
|
|
231
|
+
console.log(`⚡ [GxP] Serving fallback for missing layout: ${fileName}`);
|
|
232
|
+
|
|
233
|
+
// CSS files get empty content
|
|
234
|
+
if (fileName.endsWith(".css")) {
|
|
235
|
+
return "/* GxP fallback: no local AdditionalStyling.css */";
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
// Vue layout components get a passthrough slot wrapper
|
|
239
|
+
if (fileName.endsWith(".vue")) {
|
|
240
|
+
return `
|
|
241
|
+
<template><slot /></template>
|
|
242
|
+
<script setup>
|
|
243
|
+
defineOptions({ inheritAttrs: false });
|
|
244
|
+
defineProps({
|
|
245
|
+
usrLang: { type: String, default: "" },
|
|
246
|
+
portalSettings: { type: Object, default: () => ({}) },
|
|
247
|
+
portalLanguage: { type: Object, default: () => ({}) },
|
|
248
|
+
portalNavigation: { type: Array, default: () => ([]) },
|
|
249
|
+
portalAssets: { type: Object, default: () => ({}) },
|
|
250
|
+
});
|
|
251
|
+
</script>`;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
return "";
|
|
255
|
+
},
|
|
256
|
+
};
|
|
257
|
+
|
|
208
258
|
// Determine if HTTPS is enabled
|
|
209
259
|
const useHttps = getHttpsConfig(env) !== false;
|
|
210
260
|
|
|
@@ -237,6 +287,8 @@ export default defineConfig(({ mode }) => {
|
|
|
237
287
|
},
|
|
238
288
|
plugins: [
|
|
239
289
|
runtimeFilesPlugin,
|
|
290
|
+
// Layout fallback must run before vue() to resolve missing @layouts/ imports
|
|
291
|
+
layoutFallbackPlugin,
|
|
240
292
|
// Source tracker must run BEFORE vue() to transform templates before compilation
|
|
241
293
|
gxpSourceTrackerPlugin(),
|
|
242
294
|
vue(),
|
package/template/vite.config.js
CHANGED
|
@@ -146,6 +146,42 @@ export default defineConfig(({ mode }) => {
|
|
|
146
146
|
// Find the toolkit path for runtime imports
|
|
147
147
|
const toolkitPath = findToolkitPath();
|
|
148
148
|
|
|
149
|
+
// Fallback plugin for missing @layouts files
|
|
150
|
+
const layoutsDir = path.resolve(process.cwd(), "theme-layouts");
|
|
151
|
+
const layoutFallbackPlugin = {
|
|
152
|
+
name: "gxp-layout-fallback",
|
|
153
|
+
resolveId(source) {
|
|
154
|
+
if (!source.startsWith("@layouts/")) return null;
|
|
155
|
+
const fileName = source.replace("@layouts/", "");
|
|
156
|
+
const localFile = path.resolve(layoutsDir, fileName);
|
|
157
|
+
if (fs.existsSync(localFile)) return null;
|
|
158
|
+
return `\0gxp-layout-fallback:${fileName}`;
|
|
159
|
+
},
|
|
160
|
+
load(id) {
|
|
161
|
+
if (!id.startsWith("\0gxp-layout-fallback:")) return null;
|
|
162
|
+
const fileName = id.replace("\0gxp-layout-fallback:", "");
|
|
163
|
+
console.log(`⚡ [GxP] Serving fallback for missing layout: ${fileName}`);
|
|
164
|
+
if (fileName.endsWith(".css")) {
|
|
165
|
+
return "/* GxP fallback: no local AdditionalStyling.css */";
|
|
166
|
+
}
|
|
167
|
+
if (fileName.endsWith(".vue")) {
|
|
168
|
+
return `
|
|
169
|
+
<template><slot /></template>
|
|
170
|
+
<script setup>
|
|
171
|
+
defineOptions({ inheritAttrs: false });
|
|
172
|
+
defineProps({
|
|
173
|
+
usrLang: { type: String, default: "" },
|
|
174
|
+
portalSettings: { type: Object, default: () => ({}) },
|
|
175
|
+
portalLanguage: { type: Object, default: () => ({}) },
|
|
176
|
+
portalNavigation: { type: Array, default: () => ([]) },
|
|
177
|
+
portalAssets: { type: Object, default: () => ({}) },
|
|
178
|
+
});
|
|
179
|
+
</script>`;
|
|
180
|
+
}
|
|
181
|
+
return "";
|
|
182
|
+
},
|
|
183
|
+
};
|
|
184
|
+
|
|
149
185
|
// Determine if HTTPS is enabled
|
|
150
186
|
const useHttps = getHttpsConfig(env) !== false;
|
|
151
187
|
|
|
@@ -175,6 +211,8 @@ export default defineConfig(({ mode }) => {
|
|
|
175
211
|
),
|
|
176
212
|
},
|
|
177
213
|
plugins: [
|
|
214
|
+
// Layout fallback must run before vue() to resolve missing @layouts/ imports
|
|
215
|
+
layoutFallbackPlugin,
|
|
178
216
|
// Source tracker must come before vue() to transform templates before compilation
|
|
179
217
|
...(gxpSourceTrackerPlugin ? [gxpSourceTrackerPlugin()] : []),
|
|
180
218
|
vue(),
|