UNPKG

rune-sdk

Version:

Build a multiplayer game played by millions! Your game runs inside the Rune app with 10 million installs across [iOS](https://apps.apple.com/app/rune-games-and-voice-chat/id1450358364) and [Android](https://play.google.com/store/apps/details?id=ai.rune.ti

41 lines (40 loc) 1.79 kB
import path from "node:path"; import { terserPlugin } from "./terser.js"; import { normalizeId } from "../lib/normalizeId.js"; export function getBuildLogicPlugin(options, logicPath) { return [ { name: "vite:rune-plugin:build", apply: "build", outputOptions: (options) => ({ ...options, generatedCode: "es5", //For other file to be called client.js entryFileNames: "client.js", // Force logic.js chunk to be named so. chunkFileNames: (chunkInfo) => { if (chunkInfo.name === "logic") { return "logic.js"; } return typeof options.chunkFileNames === "function" ? options.chunkFileNames(chunkInfo) : options.chunkFileNames; }, // Force all logic related code into a logic.js chunk. manualChunks: (id, { getModuleInfo }) => { const moduleInfo = getModuleInfo(id); const platformAgnosticId = normalizeId(id); const platformAgnosticLogicPath = logicPath.split(path.sep).join("/"); const platformAgnosticImporters = moduleInfo ? moduleInfo.importers.map((importer) => importer.split(path.sep).join("/")) : []; if (platformAgnosticId === platformAgnosticLogicPath || platformAgnosticImporters.includes(platformAgnosticLogicPath)) { return "logic"; } }, }), }, terserPlugin(options.minifyLogic ?? false), ]; }