mirror of
https://github.com/tiennm99/HugoBlox-kit.git
synced 2026-10-13 10:15:22 +00:00
fix(ci): use classic JSX + global Preact to fix js.Build resolution
landing-page starter, which uses preact blocks, was only working only in monorepo due to Preact installed in root package.json but not starter package.json. - Switch js.Build to classic JSX with global factory in `modules/blox-tailwind/layouts/_partials/libraries.html` (JSX=transform, JSXFactory=preact.h, JSXFragment=preact.Fragment) - Update `modules/blox-tailwind/blox/hero/client.jsx` to call `preact.render` and remove `preact` import - Remove `preact` import from `modules/blox-tailwind/blox/shared/js/components/Icon.jsx` (classic JSX uses global `preact.h`) - Keep vendored `assets/dist/lib/preact/preact.min.js` and load it only when `needs_preact` is set - Fixes CI error “Could not resolve preact/jsx-runtime” without requiring `preact` in each starter
This commit is contained in:
1 parent
29375a9c39
commit
c843d01cf8
3 files changed
+6
-5
No files matched your search
@@ -3,7 +3,7 @@
|
||||
* Uses the shared component for consistency
|
||||
*/
|
||||
|
||||
import {render} from "preact";
|
||||
// Use global preact (loaded via script tag) with classic JSX transform
|
||||
import {HeroBlock} from "./component.jsx";
|
||||
|
||||
// Render function - immediately renders Hero components
|
||||
@@ -18,7 +18,7 @@ function renderHeroBlocks() {
|
||||
const props = JSON.parse(propsData);
|
||||
|
||||
// Render the Preact component into the container
|
||||
render(<HeroBlock {...props} />, block);
|
||||
preact.render(<HeroBlock {...props} />, block);
|
||||
console.debug(`✓ Hero block "${block.id}" rendered with Preact`);
|
||||
} catch (error) {
|
||||
console.error(`Failed to render Hero block "${block.id}":`, error);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {h} from "preact";
|
||||
// Use classic JSX transform with global preact; no direct import
|
||||
|
||||
/**
|
||||
* Icon component
|
||||
|
||||
@@ -26,8 +26,9 @@
|
||||
{{/* Build the client-side JSX using Hugo's official integration */}}
|
||||
{{ $jsx_opts := dict
|
||||
"targetPath" (printf "assets/js/preact-built/%s.js" $block_type)
|
||||
"JSX" "automatic"
|
||||
"JSXImportSource" "preact"
|
||||
"JSX" "transform"
|
||||
"JSXFactory" "preact.h"
|
||||
"JSXFragment" "preact.Fragment"
|
||||
"format" "iife"
|
||||
"minify" hugo.IsProduction
|
||||
"sourceMap" (cond hugo.IsDevelopment "external" "")
|
||||
|
||||
Reference in new issue
Block a user