mirror of
https://github.com/storytold/spark.git
synced 2026-10-17 00:12:59 +00:00
Copy static files to docs/site directory
This commit is contained in:
+2
-1
@@ -14,7 +14,8 @@
|
|||||||
"rust/forge-internal-rs/pkg",
|
"rust/forge-internal-rs/pkg",
|
||||||
"src/vrButton.ts",
|
"src/vrButton.ts",
|
||||||
"site",
|
"site",
|
||||||
"site-repo"
|
"site-repo",
|
||||||
|
"docs"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"formatter": {
|
"formatter": {
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
dist
|
||||||
|
examples
|
||||||
|
viewer
|
||||||
+2
-2
@@ -221,7 +221,7 @@
|
|||||||
panel.querySelectorAll('.example-link').forEach((link) => {
|
panel.querySelectorAll('.example-link').forEach((link) => {
|
||||||
link.addEventListener('click', (e) => {
|
link.addEventListener('click', (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const path = link.getAttribute('href').substring(1);
|
const path = link.getAttribute('href');
|
||||||
iframe.src = path;
|
iframe.src = path;
|
||||||
|
|
||||||
console.log('path:', path);
|
console.log('path:', path);
|
||||||
@@ -286,7 +286,7 @@
|
|||||||
mobilePanel.querySelectorAll('.example-link').forEach(link => {
|
mobilePanel.querySelectorAll('.example-link').forEach(link => {
|
||||||
link.addEventListener('click', (e) => {
|
link.addEventListener('click', (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const path = link.getAttribute('href').substring(1);
|
const path = link.getAttribute('href');
|
||||||
|
|
||||||
iframe.src = path;
|
iframe.src = path;
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -24,7 +24,7 @@
|
|||||||
"build:watch": "onchange 'src/**/*.{ts,glsl}' -- npm run build:dev",
|
"build:watch": "onchange 'src/**/*.{ts,glsl}' -- npm run build:dev",
|
||||||
"clean": "rm -rf dist/ && rm -rf node_modules/ && rm -rf rust/target/ && rm -rf rust/forge-internal-rs/pkg/ && npm run assets:clean",
|
"clean": "rm -rf dist/ && rm -rf node_modules/ && rm -rf rust/target/ && rm -rf rust/forge-internal-rs/pkg/ && npm run assets:clean",
|
||||||
"dev": "npm run build:dev && (vite --host & npm run build:watch)",
|
"dev": "npm run build:dev && (vite --host & npm run build:watch)",
|
||||||
"docs": "mkdocs serve",
|
"docs": "node scripts/clean-site-files.js && node scripts/copy-site-files.js && mkdocs serve",
|
||||||
"format": "biome format .",
|
"format": "biome format .",
|
||||||
"format:fix": "biome format . --fix",
|
"format:fix": "biome format . --fix",
|
||||||
"lint": "biome check .",
|
"lint": "biome check .",
|
||||||
|
|||||||
@@ -1,32 +0,0 @@
|
|||||||
import fs from "node:fs";
|
|
||||||
import { copyFile, mkdir, rename, rmSync } from "node:fs/promises";
|
|
||||||
import path from "node:path";
|
|
||||||
|
|
||||||
function copyDir(src, dest) {
|
|
||||||
if (!fs.existsSync(dest)) {
|
|
||||||
fs.mkdirSync(dest, { recursive: true });
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const entry of fs.readdirSync(src, { withFileTypes: true })) {
|
|
||||||
const srcPath = path.join(src, entry.name);
|
|
||||||
const destPath = path.join(dest, entry.name);
|
|
||||||
|
|
||||||
if (entry.isDirectory()) {
|
|
||||||
copyDir(srcPath, destPath);
|
|
||||||
} else {
|
|
||||||
fs.copyFileSync(srcPath, destPath);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Example usage:
|
|
||||||
const sourceDir = "examples";
|
|
||||||
const destinationDir = "site/examples";
|
|
||||||
|
|
||||||
copyDir("examples", "site/examples");
|
|
||||||
await copyFile("index.html", "site/examples/index.html");
|
|
||||||
await rename("site/examples/viewer", "site/viewer");
|
|
||||||
await mkdir("site/examples/vendor", { recursive: true });
|
|
||||||
copyDir("node_modules/three", "site/examples/js/vendor/three");
|
|
||||||
copyDir("dist", "site/dist");
|
|
||||||
console.log("Site generated in site directory.");
|
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
import fs from "node:fs";
|
||||||
|
import { copyFile, mkdir, rename, rm } from "node:fs/promises";
|
||||||
|
import path from "node:path";
|
||||||
|
|
||||||
|
const examplesDirectory = "docs/examples";
|
||||||
|
if (fs.existsSync(examplesDirectory)) {
|
||||||
|
await rm(examplesDirectory, { recursive: true, force: true });
|
||||||
|
console.log(`Directory ${examplesDirectory} deleted`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const distDirectory = "docs/dist";
|
||||||
|
if (fs.existsSync(distDirectory)) {
|
||||||
|
await rm(distDirectory, { recursive: true, force: true });
|
||||||
|
console.log(`Directory ${distDirectory} deleted`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const viewerDirectory = "docs/viewer";
|
||||||
|
if (fs.existsSync(viewerDirectory)) {
|
||||||
|
await rm(viewerDirectory, { recursive: true, force: true });
|
||||||
|
console.log(`Directory ${viewerDirectory} deleted`);
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
import fs from "node:fs";
|
||||||
|
import { copyFile, mkdir, rename } from "node:fs/promises";
|
||||||
|
import path from "node:path";
|
||||||
|
|
||||||
|
function copyDir(src, dest) {
|
||||||
|
if (!fs.existsSync(dest)) {
|
||||||
|
fs.mkdirSync(dest, { recursive: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const entry of fs.readdirSync(src, { withFileTypes: true })) {
|
||||||
|
const srcPath = path.join(src, entry.name);
|
||||||
|
const destPath = path.join(dest, entry.name);
|
||||||
|
|
||||||
|
if (entry.isDirectory()) {
|
||||||
|
copyDir(srcPath, destPath);
|
||||||
|
} else {
|
||||||
|
fs.copyFileSync(srcPath, destPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Copy static files to docs directory.
|
||||||
|
copyDir("examples", "docs/examples");
|
||||||
|
await copyFile("examples.html", "docs/examples/index.html");
|
||||||
|
await rename("docs/examples/viewer", "docs/viewer");
|
||||||
|
await mkdir("docs/examples/vendor", { recursive: true });
|
||||||
|
copyDir("node_modules/three", "docs/examples/js/vendor/three");
|
||||||
|
copyDir("dist", "docs/dist");
|
||||||
|
console.log("Site generated in docs directory.");
|
||||||
Reference in New Issue
Block a user