Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
min-release-age=4
99 changes: 1 addition & 98 deletions documentation/docs/integrate/vite-plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,101 +15,4 @@ next:

For easy integration with popular frontend frameworks like React, Angular, Vue, etc. we provide a plugin for [Vite](https://vitejs.dev/){target="_blank"}.

::: tip
We think it's good to put all the frontend code in a separate folder for better separation of concerns. It also simplifies the build process. For this, we use the `webui` folder throughout the documentation.
:::

::: info NOTE
We also provide a creator app with templates for the most used frameworks. We recommend checking this out first before using this plugin. More information can be found in [our quick start](../introduction/quick-start).
:::

## Installation

You can simply install the plugin as dev-dependency using NPM.

```bash
npm install --save-dev @jitar/plugin-vite
```

Next it has to be added to the Vite config file.

```ts
// vite.config.js
import jitar, { JitarConfig } from '@jitar/plugin-vite';
import { defineConfig } from 'vite';

const JITAR_URL = 'http://localhost:3000';
const JITAR_SEGMENTS = ['frontend'];
const JITAR_MIDDLEWARES = ['./requesterMiddleware'];

const jitarConfig: JitarConfig = {
projectRoot: '../../',
sourceRoot: '../',
configurationFile: './jitar.json',
environmentFile: './dev.env',
jitarUrl: JITAR_URL,
segments: JITAR_SEGMENTS,
middleware: JITAR_MIDDLEWARES
};

export default defineConfig({
publicDir: 'src/webui/public',
build: {
assetsDir: 'webui',
emptyOutDir: false
},
plugins: [
jitar(jitarConfig)
]
});
```

The plugin configuration has 5 parameters:

1. projectRoot - The root directory of the the project relative to the Vite configuration.
1. sourceRoot - The source directory relative to the Vite configuration.
1. configurationFile - The Jitar configuration file relative to the project root. Jitar uses `./jitar.json` by default.
1. environmentFile - The environment file relative to the project root. Is only loaded when configured.
1. jitarUrl - The URL of the Jitar instance. Jitar uses by default `http://localhost:3000`, but can be configured differently.
1. segments - The segments to use for the client app. This is an array of strings. The default is an empty array.
1. middlewares - The middlewares to use for calling remote procedures. This is an array of strings. The default is an empty array.

To build the segments, an additional tsconfig file is required to compile the source code. The configuration is also used to exclude the `webui` folder from the TypeScript compilation.

```json
// tsconfig.jitar.json
{
"extends": "./tsconfig.json",
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"noEmit": false,
"rootDir": "./src",
"outDir": "./dist"
},
"include": ["src"],
"exclude": ["src/webui"]
}
```

Finally, the TypeScript compilation needs to be set as the last step in the package.json file.

```json
{
"build": "npm run build-domain && npm run build-webui",
"build-domain": "rm -rf dist && tsc -p tsconfig.jitar.json && jitar build",
"build-webui": "vite build",
}
```

::: tip
Checkout our demo project [Comify](https://github.com/MaskingTechnology/comify){target="_blank"} for a complete working setup.
:::

## Usage

For development you can run Vite as you would normally do. The only requirement is that an instance of Jitar must already run in the background. For production you can build the project and use Jitar as your web server.

::: info IMPORTANT
Jitar currently doesn’t support hot reloads. This means that the Jitar server needs to get restarted every time the backend functions are created or updated.
:::
Documentation can be found on the [Jitar docs](https://docs.jitar.dev/integrate/vite-plugin.html).
2 changes: 1 addition & 1 deletion examples/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.jitar
build
dist
node_modules
package-lock.json
2 changes: 1 addition & 1 deletion examples/access-protection/jitar.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"source": "./dist",
"target": "./.jitar"
"target": "./build"
}
4 changes: 2 additions & 2 deletions examples/access-protection/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"license": "MIT",
"private": true,
"scripts": {
"build": "rimraf dist .jitar && tsc && jitar build",
"build": "rimraf dist build && tsc && jitar build",
"standalone": "jitar start --service=services/standalone.json",
"gateway": "jitar start --service=services/gateway.json",
"worker-public": "jitar start --service=services/public.json",
Expand All @@ -16,6 +16,6 @@
"typescript": "5.9.3"
},
"dependencies": {
"jitar": "0.10.5"
"jitar": "0.11.0"
}
}
2 changes: 1 addition & 1 deletion examples/data-transportation/jitar.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"source": "./dist",
"target": "./.jitar"
"target": "./build"
}
4 changes: 2 additions & 2 deletions examples/data-transportation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"license": "MIT",
"private": true,
"scripts": {
"build": "rimraf dist .jitar && tsc && jitar build",
"build": "rimraf dist build && tsc && jitar build",
"standalone": "jitar start --service=services/standalone.json",
"gateway": "jitar start --service=services/gateway.json",
"worker-account": "jitar start --service=services/account.json",
Expand All @@ -16,6 +16,6 @@
"typescript": "5.9.3"
},
"dependencies": {
"jitar": "0.10.5"
"jitar": "0.11.0"
}
}
2 changes: 1 addition & 1 deletion examples/error-handling/jitar.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"source": "./dist",
"target": "./.jitar"
"target": "./build"
}
4 changes: 2 additions & 2 deletions examples/error-handling/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"license": "MIT",
"private": true,
"scripts": {
"build": "rimraf dist .jitar && tsc && jitar build",
"build": "rimraf dist build && tsc && jitar build",
"standalone": "jitar start --service=services/standalone.json",
"gateway": "jitar start --service=services/gateway.json",
"worker-data": "jitar start --service=services/data.json",
Expand All @@ -16,6 +16,6 @@
"typescript": "5.9.3"
},
"dependencies": {
"jitar": "0.10.5"
"jitar": "0.11.0"
}
}
2 changes: 1 addition & 1 deletion examples/health-checks/jitar.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"source": "./dist",
"target": "./.jitar"
"target": "./build"
}
4 changes: 2 additions & 2 deletions examples/health-checks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
"license": "MIT",
"private": true,
"scripts": {
"build": "rimraf dist .jitar && tsc && jitar build",
"build": "rimraf dist build && tsc && jitar build",
"standalone": "jitar start --service=services/standalone.json"
},
"devDependencies": {
"rimraf": "6.1.2",
"typescript": "5.9.3"
},
"dependencies": {
"jitar": "0.10.5"
"jitar": "0.11.0"
}
}
2 changes: 1 addition & 1 deletion examples/hello-world/jitar.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"source": "./dist",
"target": "./.jitar"
"target": "./build"
}
4 changes: 2 additions & 2 deletions examples/hello-world/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
"license": "MIT",
"private": true,
"scripts": {
"build": "rimraf dist .jitar && tsc && jitar build",
"build": "rimraf dist build && tsc && jitar build",
"standalone": "jitar start --service=services/standalone.json"
},
"devDependencies": {
"rimraf": "6.1.2",
"typescript": "5.9.3"
},
"dependencies": {
"jitar": "0.10.5"
"jitar": "0.11.0"
}
}
2 changes: 1 addition & 1 deletion examples/load-balancing/jitar.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"source": "./dist",
"target": "./.jitar"
"target": "./build"
}
4 changes: 2 additions & 2 deletions examples/load-balancing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"license": "MIT",
"private": true,
"scripts": {
"build": "rimraf dist .jitar && tsc && jitar build",
"build": "rimraf dist build && tsc && jitar build",
"standalone": "jitar start --service=services/standalone.json",
"gateway": "jitar start --service=services/gateway.json",
"worker1": "jitar start --service=services/worker1.json",
Expand All @@ -16,6 +16,6 @@
"typescript": "5.9.3"
},
"dependencies": {
"jitar": "0.10.5"
"jitar": "0.11.0"
}
}
2 changes: 1 addition & 1 deletion examples/middleware/jitar.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"source": "./dist",
"target": "./.jitar"
"target": "./build"
}
4 changes: 2 additions & 2 deletions examples/middleware/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
"license": "MIT",
"private": true,
"scripts": {
"build": "rimraf dist .jitar && tsc && jitar build",
"build": "rimraf dist build && tsc && jitar build",
"standalone": "jitar start --service=services/standalone.json"
},
"devDependencies": {
"rimraf": "6.1.2",
"typescript": "5.9.3"
},
"dependencies": {
"jitar": "0.10.5"
"jitar": "0.11.0"
}
}
2 changes: 1 addition & 1 deletion examples/multi-version/jitar.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"source": "./dist",
"target": "./.jitar"
"target": "./build"
}
4 changes: 2 additions & 2 deletions examples/multi-version/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
"license": "MIT",
"private": true,
"scripts": {
"build": "rimraf dist .jitar && tsc && jitar build",
"build": "rimraf dist build && tsc && jitar build",
"standalone": "jitar start --service=services/standalone.json"
},
"devDependencies": {
"rimraf": "6.1.2",
"typescript": "5.9.3"
},
"dependencies": {
"jitar": "0.10.5"
"jitar": "0.11.0"
}
}
2 changes: 1 addition & 1 deletion examples/resources/jitar.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"source": "./dist",
"target": "./.jitar",
"target": "./build",
"segments": "./segments",
"resources": "./resources"
}
4 changes: 2 additions & 2 deletions examples/resources/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
"license": "MIT",
"private": true,
"scripts": {
"build": "rimraf dist .jitar && tsc && jitar build",
"build": "rimraf dist build && tsc && jitar build",
"standalone": "jitar start --service=services/standalone.json"
},
"devDependencies": {
"rimraf": "6.1.2",
"typescript": "5.9.3"
},
"dependencies": {
"jitar": "0.10.5"
"jitar": "0.11.0"
}
}
2 changes: 1 addition & 1 deletion examples/segmentation/jitar.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"source": "./dist",
"target": "./.jitar",
"target": "./build",
"segments": "./segments"
}
4 changes: 2 additions & 2 deletions examples/segmentation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"license": "MIT",
"private": true,
"scripts": {
"build": "rimraf dist .jitar && tsc && jitar build",
"build": "rimraf dist build && tsc && jitar build",
"standalone": "jitar start --service=services/standalone.json",
"gateway": "jitar start --service=services/gateway.json",
"worker-data": "jitar start --service=services/data.json",
Expand All @@ -16,6 +16,6 @@
"typescript": "5.9.3"
},
"dependencies": {
"jitar": "0.10.5"
"jitar": "0.11.0"
}
}
Loading
Loading