9 Star 7 Fork 0

masterk3ze/cazomas-screeps-arena

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
rollup.config.js 1.96 KB
一键复制 编辑 原始数据 按行查看 历史
masterkeze 提交于 2022-11-07 16:34 . init commit
"use strict";
import clear from "rollup-plugin-clear";
import resolve from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";
import typescript from "rollup-plugin-typescript2";
import fg from "fast-glob";
let targetArena = "";
if (process.argv[3] === "--config-") {
// we running dynamic mode
targetArena = process.argv[4] || "";
} else if (process.argv[3] === "--environment") {
targetArena = process.env.DEST;
}
function getOptions(arenaSrc) {
const outDir = arenaSrc.replace("src/", "dist/");
const options = {
input: `${arenaSrc}/main.ts`,
external: ["game", "game/prototypes", "game/constants", "game/utils", "game/path-finder", "arena", "game/visual"], // <-- suppresses the warning
output: {
dir: outDir,
format: "esm",
entryFileNames: "[name].mjs",
sourcemap: false,
preserveModules: true,
preserveModulesRoot: arenaSrc,
paths: path => {
// https://rollupjs.org/guide/en/#outputpaths
// TS requires that we use non-relative paths for these "ambient" modules
// The game requires relative paths, so prefix all game modules with "/" in the output bundle
if (path.startsWith("game") || path.startsWith("arena")) {
return "/" + path;
}
}
},
plugins: [
clear({ targets: targetArena === "" ? ["dist"] : [outDir] }), // If targeted build, only clear target sub-directory
resolve({ rootDir: "src" }),
commonjs(),
typescript({ tsconfig: "./tsconfig.json" })
]
};
return options;
}
const arenas = fg.sync(`src/*arena_*${targetArena}*`, { onlyDirectories: true });
if (arenas.length === 0) {
throw new Error("No matching arenas found in src/. Exiting");
} else {
if (targetArena === "") {
console.log(`No arena targeted. Building all ${arenas.length} arenas.`);
} else {
console.log(`Buidling ${arenas.length} arena(s) for target "${targetArena}"`);
}
}
export default arenas.map(getOptions);
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/masterk3ze/cazomas-screeps-arena.git
git@gitee.com:masterk3ze/cazomas-screeps-arena.git
masterk3ze
cazomas-screeps-arena
cazomas-screeps-arena
master

搜索帮助