21 lines
865 B
JavaScript
21 lines
865 B
JavaScript
import { cpSync, readFileSync, writeFileSync } from "node:fs";
|
|
import { resolve, dirname } from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
const src = resolve(__dirname, "../build/web");
|
|
const dest = resolve(__dirname, "../../../apps/web/public/flutter");
|
|
|
|
cpSync(src, dest, { recursive: true });
|
|
console.log(`Copied Flutter build: ${src} → ${dest}`);
|
|
|
|
// Extract buildConfig from flutter_bootstrap.js so the React app can fetch it
|
|
const bootstrap = readFileSync(resolve(dest, "flutter_bootstrap.js"), "utf-8");
|
|
const match = bootstrap.match(/_flutter\.buildConfig\s*=\s*({.*?});/);
|
|
if (match) {
|
|
writeFileSync(resolve(dest, "build_config.json"), match[1]);
|
|
console.log("Extracted build_config.json");
|
|
} else {
|
|
console.warn("Could not extract buildConfig from flutter_bootstrap.js");
|
|
}
|