A collection of useful vite plugins for Phaser development. Checkout the main phaserquick repo for more easy to use packages.
This plugin provides additional build information an embeds this into the index.html
making it available at window.version
.
npm i @phaserquick/vite-plugins
import { getBuildInfo } from '@phaserquick/vite-plugins';
export default {
//...
plugins: [getBuildInfo()]
};
const version = window.version;
console.log(version.buildTimestamp); // "2024-03-16T03:04:24.382Z"
console.log(version.commit); // "c986ef6f" or undefined if not using source control
{
// Version related information for this game.
version: {
// Timestamp of the build for version tracking.
buildTimestamp: string;
// Optional commit hash associated with the build.
commit?: string | null;
// Dependencies used in the application, stored as key-value pairs.
dependencies: {
[key: string]: string;
}
}
}
If not using the phaserquick
boilerplate, you can configure the below typings for the window object to utilise autocomplete within TypeScript.
//global.d.ts
declare global {
interface Window {
// Version related information for this game.
version: {
// Timestamp of the build for version tracking.
buildTimestamp: string;
// Optional commit hash associated with the build.
commit?: string | null;
// Dependencies used in the application, stored as key-value pairs.
dependencies: {
[key: string]: string;
};
};
}
}
Passing dependencies to the build information options will include a list of dependencies on the version object. Useful to show you what dependencies are part of the build.
export default {
//...
plugins: [getBuildInfo({ dependencies: 'my-package' })]
};
const version = window.version;
console.log(version.dependencies); // {"my-package": "3.00.0"}