mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-05-02 06:46:06 -04:00
ci: auto generate typescript bindings (#56)
This PR - removes `tauriModel.ts` from git and instead - generates `tauriModel.ts` everytime `vite` starts or `vite` detects a change in `swap/src/` To do that I have introduced the `gen-bindings` and `check-bindings` commands as well as improved documentation. Following this PR, the Typescript bindings to our Tauri commands will be automatically re-generated upon the instant a source file is changed! This closes #49
This commit is contained in:
parent
bcd2d95f03
commit
1fe6391b7b
6 changed files with 77 additions and 293 deletions
|
@ -2,13 +2,33 @@ import react from "@vitejs/plugin-react";
|
|||
import { internalIpV4 } from "internal-ip";
|
||||
import { defineConfig } from "vite";
|
||||
import tsconfigPaths from "vite-tsconfig-paths";
|
||||
import { watch } from "vite-plugin-watch";
|
||||
import path from "path";
|
||||
|
||||
// @ts-expect-error process is a nodejs global
|
||||
const mobile = !!/android|ios/.exec(process.env.TAURI_ENV_PLATFORM);
|
||||
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig(async () => ({
|
||||
plugins: [react(), tsconfigPaths()],
|
||||
plugins: [
|
||||
react(),
|
||||
tsconfigPaths(),
|
||||
// automatically regenerate the typescript bindings when there's a change
|
||||
watch({
|
||||
pattern: ["../swap/src/**/*"],
|
||||
command: "yarn run gen-bindings",
|
||||
silent: true,
|
||||
}),
|
||||
// this makes it so that the former plugin can recognize changes to the swap crate
|
||||
{
|
||||
name: "watch-swap",
|
||||
configureServer(server) {
|
||||
server.watcher.add(path.resolve(__dirname, "../swap/src"));
|
||||
},
|
||||
},
|
||||
// VitePluginRestart({
|
||||
// restart: ["../swap/src/**/*"]
|
||||
// })
|
||||
],
|
||||
// Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build`
|
||||
//
|
||||
// 1. prevent vite from obscuring rust errors
|
||||
|
@ -27,7 +47,7 @@ export default defineConfig(async () => ({
|
|||
: undefined,
|
||||
watch: {
|
||||
// 3. tell vite to ignore watching `src-tauri`
|
||||
ignored: ["**/src-tauri/**"],
|
||||
ignored: ["**/src-tauri/**", "!../swap/**/*"],
|
||||
},
|
||||
},
|
||||
}));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue