foundryvtt-dice-tower/vite.config.ts
Arindy f32f9f2806
All checks were successful
ci / ci (push) Successful in 26s
[major]: initial ci
2025-03-01 22:08:44 +01:00

67 lines
2.2 KiB
TypeScript

import * as fsPromises from "fs/promises";
import copy from "rollup-plugin-copy";
import scss from "rollup-plugin-scss";
import {defineConfig, Plugin} from "vite";
export default defineConfig({
build: {
sourcemap: true,
rollupOptions: {
input: "src/ts/dice-tower.ts",
output: {
entryFileNames: "scripts/[name].js",
dir: "dist",
format: "es",
assetFileNames: "[name][extname]"
},
},
},
plugins: [
scss({
name: "styles/style.css",
sourceMap: true,
watch: ["src/styles/*.scss"],
}),
copy({
targets: [
{ src: "src/languages", dest: "dist" },
{ src: "src/templates", dest: "dist" },
{ src: "src/libs", dest: "dist" },
{ src: "src/textures", dest: "dist" },
],
hook: "writeBundle",
}),
updateModuleManifestPlugin(),
],
});
function updateModuleManifestPlugin(): Plugin {
return {
name: "update-module-manifest",
async writeBundle(): Promise<void> {
const packageContents = JSON.parse(
await fsPromises.readFile("./package.json", "utf-8")
) as Record<string, unknown>;
const version = (packageContents.version as string);
const description = (packageContents.description as string);
const manifestContents: string = await fsPromises.readFile(
"src/module.json",
"utf-8"
);
const manifestJson = JSON.parse(manifestContents) as Record<
string,
unknown
>;
manifestJson["version"] = version;
manifestJson["description"] = description;
const baseUrl = `https://git.arindy.de/arindy/foundryvtt-dice-tower/releases/download`;
manifestJson["manifest"] = `${baseUrl}/latest/module.json`;
manifestJson["download"] = `${baseUrl}/${version}/foundryvtt-dice-tower-${version}.zip`;
await fsPromises.writeFile(
"dist/module.json",
JSON.stringify(manifestJson, null, 4)
);
},
};
}