@kubejs/plugin
TypeScript icon, indicating that this package has built-in type declarations

1.1.5 • Public • Published

Introduce

A long time ago when first time I met KubeJS mod I was so excited about it. I first looked to mod but couldn't use it cause time and knowledge. But now when I improved my self as JavaScript developer I decided to make a modpack with KubeJS mod. But regular usage of KubeJS mod is not enough for me. For that I decided to use vite as bundler for KubeJS scripts. It's small and scratch project. Please give a feedback if you have any idea.

Pre-requirements

  • NodeJS - I recommend to use LTS version.
  • Yarn - I recommend to use yarn 2.
  • KubeJS - I recommend to use latest version.
  • ProbeJS - required for full typescript support.

Usage

Create new minecraft project in one of these platforms such as curseforge, modrinth, etc...
Then setup new node project on instance directory.

cd /path/to/instance
npm init -y
# or
yarn init -y # for yarn 1
yarn init -y -2 # for yarn 2

Add @kubejs/plugin to your project.

npm install @kubejs/plugin
# or
yarn add @kubejs/plugin

Add these scripts to your package.json file.

{
  "scripts": {
    "build": "kubejs build",
    "watch": "kubejs build --watch"
  }
}

Add that typing to vite environment file (vite-env.d.ts).

/// <reference types="@kubejs/plugin/probe.d.ts" />

Now you can run npm run build or yarn build to build your scripts for production.
Or you can run npm run watch or yarn watch to start development statement.

You can add additional buildable config in vite.config.ts. But in my opinion I made everything which I can. After that you can start writing your scripts in src directory, and it will automatically will be built into kubejs/*_scripts directories depends on entry file. You can find more information about KubeJS mod in here.

File Structure

Here have 3 entry points for vite build.

  • src/client.ts - This file will be built into kubejs/client_scripts directory, and it will be loaded on client side.
  • src/server.ts - This file will be built into kubejs/server_scripts directory, and it will be loaded on server side.
  • src/startup.ts - This file will be built into kubejs/startup_scripts directory, and it will be loaded on startup.

License

This project is licensed under the MIT License - see the LICENSE file for details

Contributing

If you have any idea, or you want to contribute to this project please open an issue or pull request. I will be happy to see your ideas and contributions.

Contact

You can contact with me via Discord or LinkedIn

TODO

  • [ ] Add framework support (React, Vue, etc...)
  • [ ] Add more examples
  • [ ] Add more documentation
  • [ ] Add more tests

Readme

Keywords

none

Package Sidebar

Install

npm i @kubejs/plugin

Weekly Downloads

4

Version

1.1.5

License

none

Unpacked Size

37.9 kB

Total Files

16

Last publish

Collaborators

  • mdreal