Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ciscoheat/vite-plugin-haxe
Run Haxe code on Vite.
https://github.com/ciscoheat/vite-plugin-haxe
haxe vite vite-plugin
Last synced: 12 days ago
JSON representation
Run Haxe code on Vite.
- Host: GitHub
- URL: https://github.com/ciscoheat/vite-plugin-haxe
- Owner: ciscoheat
- License: mit
- Created: 2023-01-16T14:56:16.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-01-17T15:27:50.000Z (almost 2 years ago)
- Last Synced: 2024-07-05T06:43:58.228Z (4 months ago)
- Topics: haxe, vite, vite-plugin
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/vite-plugin-haxe
- Size: 21.5 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# vite-plugin-haxe
Lets you run [Haxe](https://haxe.org/) code in your [Vite](https://vitejs.dev/) project. Supports client-side javascript currently.
## Installation & Configuration
Prerequisites: [Haxe](https://haxe.org/) and [Node.js](https://nodejs.org/).
`npm` is gladly substituted for [pnpm](https://pnpm.io/).Open a terminal in your project folder and execute this:
```bash
npm create vite@latest my-haxe-app --template vanilla
cd my-haxe-app
npm install
npm install -D vite-plugin-haxe
```Add a **vite.config.js**:
```js
import { defineConfig } from "vite";
import haxe from "vite-plugin-haxe";/** @type {import('vite').UserConfig} */
export default defineConfig({
plugins: [haxe()],
});
```Add/edit the following files:
**main.js**
```js
import "./style.css";
import "./main.hxml";
```**main.hxml**
```bash
-cp src
-main Main
-dce full# -js isn't needed, but helpful for IDE's.
-js main.js-D source-map-content
-debug
```**src/Main.hx**
```haxe
package;import js.Browser.document;
import js.html.ButtonElement;class Main {
static function main() {
document.getElementById('app')
.innerHTML = '
';Counter.setupCounter(cast(document.querySelector('#counter'), ButtonElement));
}
}class Counter {
public static function setupCounter(element:ButtonElement) {
var counter = 0;
final setCounter = (count:Int) -> {
counter = count;
element.innerHTML = 'count is $counter';
}
element.addEventListener('click', () -> setCounter(counter + 1));
setCounter(0);
}
}
```Start the fun with `npm run dev`.