vite-plugin-godot
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

vite-plugin-godot

Embed and bundle Godot 4.x games using Vite.

npm license

The plugin allows you to export your Godot game directly to the public folder. The dev server will automatically include the appropriate headers that will make the page cross-origin isolated (required for SharedArrayBuffer).

See example in examples/vanilla.

Usage

Install the package:

npm install vite-plugin-godot -D

Add the plugin to vite.config.js:

import { defineConfig } from 'vite';
import godotPlugin from 'vite-plugin-godot';

export default defineConfig({
  plugins: [
    godotPlugin({
      // Set this to your exported name
      projectName: 'example2d',
      // Reload the page when detected changes in main.js
      reload: ['src/main.js'],
    }),
  ],
});

Make sure you have a canvas element somewhere in your DOM, then add the following to your index.html:

<script src="$GODOT_JS_FILE"></script>
<script>
  const GODOT_CONFIG = $GODOT_CONFIG;
  window.engine = new Engine(GODOT_CONFIG);
</script>

Now you can start the game in your script:

window.engine.startGame();

Export

Export the game using Web preset and set the directory to the public folder.

You can read more about exporting HTML in Godot docs.

License

This project is licensed under the MIT License.

Readme

Keywords

Package Sidebar

Install

npm i vite-plugin-godot

Weekly Downloads

5

Version

1.0.0

License

MIT

Unpacked Size

10.9 kB

Total Files

6

Last publish

Collaborators

  • itskaynine