Skip to content

Commit 65e7d1e

Browse files
committed
setup viewer on index
1 parent 3eb878f commit 65e7d1e

3 files changed

Lines changed: 26 additions & 1 deletion

File tree

rspack.config.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ class RspackAssetsManifestPlugin {
1414
compiler.options.output.path,
1515
"assets.json",
1616
);
17+
18+
// Ensure the directory exists
19+
const outputDir = path.dirname(outputPath);
20+
if (!fs.existsSync(outputDir)) {
21+
fs.mkdirSync(outputDir, { recursive: true });
22+
}
23+
1724
fs.writeFileSync(outputPath, JSON.stringify(assets.entrypoints, null, 2));
1825
});
1926
}
@@ -96,6 +103,7 @@ export default (env, args) => {
96103
new ProgressPlugin(),
97104
new HtmlRspackPlugin({
98105
title: "neuroglancer",
106+
template: "./src/index.html",
99107
}),
100108
new RspackAssetsManifestPlugin(),
101109
],

src/index.html

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title><%= htmlRspackPlugin.options.title %></title>
7+
</head>
8+
<body class="neuroglass-theme">
9+
<script>
10+
window.addEventListener('DOMContentLoaded', function() {
11+
if (window.setupDefaultViewer) {
12+
window.setupDefaultViewer();
13+
}
14+
});
15+
</script>
16+
</body>
17+
</html>

src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ declare let viewer: Viewer | undefined;
4040

4141
declare const MANUAL_LOAD: string | undefined;
4242

43-
if (!MANUAL_LOAD) {
43+
if (!MANUAL_LOAD || window.location.pathname === "/") {
4444
setupDefaultViewer();
4545
document.body.classList.add("neuroglass-theme");
4646
}

0 commit comments

Comments
 (0)