@gxp-dev/tools 2.0.38 → 2.0.40
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 +58 -0
- package/template/vite.config.js +46 -0
package/package.json
CHANGED
package/runtime/vite.config.js
CHANGED
|
@@ -205,6 +205,62 @@ 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
|
+
enforce: "pre",
|
|
215
|
+
resolveId(source) {
|
|
216
|
+
// Handle @layouts/ alias imports
|
|
217
|
+
if (source.startsWith("@layouts/")) {
|
|
218
|
+
const fileName = source.replace("@layouts/", "");
|
|
219
|
+
const localFile = path.resolve(layoutsDir, fileName);
|
|
220
|
+
if (fs.existsSync(localFile)) return null;
|
|
221
|
+
return `\0gxp-layout-fallback:${fileName}`;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// Handle already-resolved absolute paths to theme-layouts/
|
|
225
|
+
if (source.startsWith(layoutsDir + "/")) {
|
|
226
|
+
if (fs.existsSync(source)) return null;
|
|
227
|
+
const fileName = source.replace(layoutsDir + "/", "");
|
|
228
|
+
return `\0gxp-layout-fallback:${fileName}`;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
return null;
|
|
232
|
+
},
|
|
233
|
+
load(id) {
|
|
234
|
+
if (!id.startsWith("\0gxp-layout-fallback:")) return null;
|
|
235
|
+
|
|
236
|
+
const fileName = id.replace("\0gxp-layout-fallback:", "");
|
|
237
|
+
console.log(`⚡ [GxP] Serving fallback for missing layout: ${fileName}`);
|
|
238
|
+
|
|
239
|
+
// CSS files get empty content
|
|
240
|
+
if (fileName.endsWith(".css")) {
|
|
241
|
+
return "/* GxP fallback: no local AdditionalStyling.css */";
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// Vue layout components get a passthrough slot wrapper
|
|
245
|
+
if (fileName.endsWith(".vue")) {
|
|
246
|
+
return `
|
|
247
|
+
<template><slot /></template>
|
|
248
|
+
<script setup>
|
|
249
|
+
defineOptions({ inheritAttrs: false });
|
|
250
|
+
defineProps({
|
|
251
|
+
usrLang: { type: String, default: "" },
|
|
252
|
+
portalSettings: { type: Object, default: () => ({}) },
|
|
253
|
+
portalLanguage: { type: Object, default: () => ({}) },
|
|
254
|
+
portalNavigation: { type: Array, default: () => ([]) },
|
|
255
|
+
portalAssets: { type: Object, default: () => ({}) },
|
|
256
|
+
});
|
|
257
|
+
</script>`;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
return "";
|
|
261
|
+
},
|
|
262
|
+
};
|
|
263
|
+
|
|
208
264
|
// Determine if HTTPS is enabled
|
|
209
265
|
const useHttps = getHttpsConfig(env) !== false;
|
|
210
266
|
|
|
@@ -237,6 +293,8 @@ export default defineConfig(({ mode }) => {
|
|
|
237
293
|
},
|
|
238
294
|
plugins: [
|
|
239
295
|
runtimeFilesPlugin,
|
|
296
|
+
// Layout fallback must run before vue() to resolve missing @layouts/ imports
|
|
297
|
+
layoutFallbackPlugin,
|
|
240
298
|
// Source tracker must run BEFORE vue() to transform templates before compilation
|
|
241
299
|
gxpSourceTrackerPlugin(),
|
|
242
300
|
vue(),
|
package/template/vite.config.js
CHANGED
|
@@ -146,6 +146,50 @@ 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
|
+
enforce: "pre",
|
|
154
|
+
resolveId(source) {
|
|
155
|
+
if (source.startsWith("@layouts/")) {
|
|
156
|
+
const fileName = source.replace("@layouts/", "");
|
|
157
|
+
const localFile = path.resolve(layoutsDir, fileName);
|
|
158
|
+
if (fs.existsSync(localFile)) return null;
|
|
159
|
+
return `\0gxp-layout-fallback:${fileName}`;
|
|
160
|
+
}
|
|
161
|
+
if (source.startsWith(layoutsDir + "/")) {
|
|
162
|
+
if (fs.existsSync(source)) return null;
|
|
163
|
+
const fileName = source.replace(layoutsDir + "/", "");
|
|
164
|
+
return `\0gxp-layout-fallback:${fileName}`;
|
|
165
|
+
}
|
|
166
|
+
return null;
|
|
167
|
+
},
|
|
168
|
+
load(id) {
|
|
169
|
+
if (!id.startsWith("\0gxp-layout-fallback:")) return null;
|
|
170
|
+
const fileName = id.replace("\0gxp-layout-fallback:", "");
|
|
171
|
+
console.log(`⚡ [GxP] Serving fallback for missing layout: ${fileName}`);
|
|
172
|
+
if (fileName.endsWith(".css")) {
|
|
173
|
+
return "/* GxP fallback: no local AdditionalStyling.css */";
|
|
174
|
+
}
|
|
175
|
+
if (fileName.endsWith(".vue")) {
|
|
176
|
+
return `
|
|
177
|
+
<template><slot /></template>
|
|
178
|
+
<script setup>
|
|
179
|
+
defineOptions({ inheritAttrs: false });
|
|
180
|
+
defineProps({
|
|
181
|
+
usrLang: { type: String, default: "" },
|
|
182
|
+
portalSettings: { type: Object, default: () => ({}) },
|
|
183
|
+
portalLanguage: { type: Object, default: () => ({}) },
|
|
184
|
+
portalNavigation: { type: Array, default: () => ([]) },
|
|
185
|
+
portalAssets: { type: Object, default: () => ({}) },
|
|
186
|
+
});
|
|
187
|
+
</script>`;
|
|
188
|
+
}
|
|
189
|
+
return "";
|
|
190
|
+
},
|
|
191
|
+
};
|
|
192
|
+
|
|
149
193
|
// Determine if HTTPS is enabled
|
|
150
194
|
const useHttps = getHttpsConfig(env) !== false;
|
|
151
195
|
|
|
@@ -175,6 +219,8 @@ export default defineConfig(({ mode }) => {
|
|
|
175
219
|
),
|
|
176
220
|
},
|
|
177
221
|
plugins: [
|
|
222
|
+
// Layout fallback must run before vue() to resolve missing @layouts/ imports
|
|
223
|
+
layoutFallbackPlugin,
|
|
178
224
|
// Source tracker must come before vue() to transform templates before compilation
|
|
179
225
|
...(gxpSourceTrackerPlugin ? [gxpSourceTrackerPlugin()] : []),
|
|
180
226
|
vue(),
|