Skip to content

Commit c921e26

Browse files
committed
ci: fix deploy to github pages not referencing correct src location
1 parent 932c8d0 commit c921e26

File tree

2 files changed

+34
-9
lines changed

2 files changed

+34
-9
lines changed

.github/workflows/deploy-demo.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ jobs:
3737
- name: Build plugin
3838
run: npm run build
3939

40+
- name: Copy dist to demo
41+
run: |
42+
mkdir -p demo/dist
43+
cp -r dist/* demo/dist/
44+
4045
- name: Setup Pages
4146
uses: actions/configure-pages@v4
4247

demo/index.html

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -144,16 +144,36 @@ <h2 onclick="toggleInstructions()">
144144
<!-- Sample queries -->
145145
<script src="./queries.js"></script>
146146

147-
<!-- Graph Plugin - DEV MODE (load source files directly) -->
147+
<!-- Graph Plugin: Load from source in dev, or from dist in production -->
148148
<script type="module">
149-
// Import all source modules
150-
import GraphPlugin from '../src/GraphPlugin.js';
151-
152-
// Register plugin with YASGUI
153-
if (window.Yasgui && window.Yasgui.Yasr) {
154-
window.Yasgui.Yasr.registerPlugin('Graph', GraphPlugin);
155-
} else {
156-
console.error('YASGUI not loaded');
149+
// Try to load from source (development mode)
150+
let pluginLoaded = false;
151+
try {
152+
const { default: GraphPlugin } = await import('../src/GraphPlugin.js');
153+
if (window.Yasgui && window.Yasgui.Yasr) {
154+
window.Yasgui.Yasr.registerPlugin('Graph', GraphPlugin);
155+
pluginLoaded = true;
156+
console.log('Graph Plugin loaded from source (dev mode)');
157+
}
158+
} catch (error) {
159+
console.log('Source not available, loading from bundle (production mode)');
160+
}
161+
162+
// Fall back to bundle if source didn't work
163+
if (!pluginLoaded) {
164+
const script = document.createElement('script');
165+
script.src = './dist/yasgui-graph-plugin.min.js';
166+
await new Promise((resolve, reject) => {
167+
script.onload = () => {
168+
console.log('Graph Plugin loaded from bundle');
169+
resolve();
170+
};
171+
script.onerror = () => {
172+
console.error('Failed to load Graph Plugin bundle');
173+
reject();
174+
};
175+
document.head.appendChild(script);
176+
});
157177
}
158178

159179
// Initialize YASGUI after plugin is registered

0 commit comments

Comments
 (0)