Skip to content

Commit

Permalink
feat: add option to specify build target
Browse files Browse the repository at this point in the history
  • Loading branch information
amrbashir committed May 6, 2023
1 parent b5a79f4 commit cc7b7ab
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 72 deletions.
60 changes: 8 additions & 52 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Unreleased

- Add option to specify the rust build target

# [3.1.1](https://github.com/amrbashir/vite-plugin-tauri/compare/v3.1.1...v3.1.0) (2023-5-5)

### What's Changed
Expand All @@ -9,13 +13,14 @@
### What's Changed

- Add a default export to the plugin which allows two styles of importing:

- Named export (current):
```ts
import { tauri } from "vite-plugin-tauri"
import { tauri } from "vite-plugin-tauri";
```
- Default export (new):
```ts
import tauri from "vite-plugin-tauri"
import tauri from "vite-plugin-tauri";
```

- Detect `Tauri.toml` file when detecting if there is a Tauri project is initialized or not.
Expand Down Expand Up @@ -45,183 +50,134 @@

- Auto-fill `beforeDevCommand` and `beforeBuildCommand` when initializing the tauri project.


# [2.2.0](https://github.com/amrbashir/vite-plugin-tauri/compare/v2.1.0...v2.2.0) (2022-07-24)

### What's Changed

- Update `vite` peerDependency to `>= 2` which adds vite@3 support



# [2.1.0](https://github.com/amrbashir/vite-plugin-tauri/compare/v2.0.0...v2.1.0) (2022-06-12)

### What's Changed

- Update `@tauri-apps/cli` to `v1.0.0`



# [2.0.0](https://github.com/amrbashir/vite-plugin-tauri/compare/v1.1.3...v2.0.0) (2022-06-04)

### Breaking Changes

- Bump minimum supported Node.js version to `14.6.0`



## [1.1.3](https://github.com/amrbashir/vite-plugin-tauri/compare/v1.1.2...v1.1.3) (2022-05-02)

### Misc.

- update dependencies


## [1.1.2](https://github.com/amrbashir/vite-plugin-tauri/compare/v1.1.1...v1.1.2) (2022-02-28)


### Bug Fixes

- fix running subcommands other than `init, dev, build` ([0094010](https://github.com/amrbashir/vite-plugin-tauri/commit/009401058c1df2b7ae1e4e2e1a28aacc5310f080))
- prevent `init` subcommand also running `dev` ([c31e1a5](https://github.com/amrbashir/vite-plugin-tauri/commit/c31e1a5982af841ca17da9f94b160518b6fc7e0d))
- resolve vite outDir before passing to tauri cli ([99f648d](https://github.com/amrbashir/vite-plugin-tauri/commit/99f648d3005b5c5e805aacdd3e0f98649a3261d2))



## [1.1.1](https://github.com/amrbashir/vite-plugin-tauri/compare/v1.1.0...v1.1.1) (2022-02-21)


### Bug Fixes

- fix `ERROR_MODULE_NOT_FOUND` due to wrong import, fix [#2](https://github.com/amrbashir/vite-plugin-tauri/issues/2) ([a0efed5](https://github.com/amrbashir/vite-plugin-tauri/commit/a0efed5659ac5e0690d0dba5401295b7eb5c0f72))



# [1.1.0](https://github.com/amrbashir/vite-plugin-tauri/compare/v1.0.0...v1.1.0) (2022-02-14)


### Features

- use `TAURI_PATH_DEPTH` env if it exists ([b5224fb](https://github.com/amrbashir/vite-plugin-tauri/commit/b5224fb48b0d96f034f8a13d5829e7c307ae2bf4))



# [1.0.0](https://github.com/amrbashir/vite-plugin-tauri/compare/v0.1.12...v1.0.0) (2022-02-12)


### Features

- use `@tauri-apps/cli` as a peerDeppendency ([ad1bbf4](https://github.com/amrbashir/vite-plugin-tauri/commit/ad1bbf47bf8c2f9b15bf51c09c16d05b7471013c))



## [0.1.12](https://github.com/amrbashir/vite-plugin-tauri/compare/v0.1.11...v0.1.12) (2022-01-12)


### Bug Fixes

- use a relative path when building, fixes [#1](https://github.com/amrbashir/vite-plugin-tauri/issues/1) ([63a2f88](https://github.com/amrbashir/vite-plugin-tauri/commit/63a2f88b985513c919b6cdf464d8bbfa33d420cd))



## 0.1.11 (2022-01-11)


### Bug Fixes

- pass vite `outDir` directly to tauri-cli, fixes [#1](https://github.com/amrbashir/vite-plugin-tauri/issues/1) ([7d0fe4c](https://github.com/amrbashir/vite-plugin-tauri/commit/7d0fe4c1c2923919beb8236eac78b920ffab0ce5))



## 0.1.10 (2021-12-12)


### Bug Fixes

- print stdout from tauri correctly ([85ed5dd](https://github.com/amrbashir/vite-plugin-tauri/commit/85ed5dd17777521aab718e6f1923c751055ff69a))



## 0.1.9 (2021-12-06)


### Misc.
- upadte `LICENSE.md`

- upadte `LICENSE.md`

## 0.1.8 (2021-12-03)


### Bug Fixes

- show correct cli name in help message


## 0.1.7 (2021-12-02)


### Bug Fixes

- use node12 compatible api to remove corrupted downloads


## 0.1.6 (2021-11-08)


### Bug Fixes

- correctly construct window title upon initialization
- print tauri help message when a subcommand isn't passed


## 0.1.5 (2021-10-31)


### Bug Fixes

- fix crash upon running the cli without passing a subcommand

## 0.1.4 (2021-10-30)


### Bug Fixes

- lower needed NodeJs version to `>=12.20`
- pass cli arguments to tauri cli in dev/build
- update node engine to `^12.20.0 || ^14.13.1 || >=16.0.0`


## 0.1.3 (2021-09-02)


### Bug Fixes

- append version to downloaded cli
- use correct tauri cli command for `vite-tauri build`


## 0.1.2 (2021-08-27)


### Bug Fixes

- fix `Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'stream'`


## 0.1.1 (2021-08-27)


### Bug Fixes

- update required node version


## 0.1.0 (2021-08-27)


### Features

- add support for all tauri cli commands and flags



21 changes: 7 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ npm i -D vite-plugin-tauri @tauri-apps/cli

```ts
// vite.config.js
import { defineConfig } from 'vite'
import tauri from "vite-plugin-tauri" // 1. import the plugin
import { defineConfig } from "vite";
import tauri from "vite-plugin-tauri"; // 1. import the plugin

export default defineConfig({
plugins: [
Expand All @@ -32,19 +32,14 @@ export default defineConfig({
// 3. optional but recommended
clearScreen: false,
server: {
open: false
open: false,
},
})
});
```

## Options
## Configuration

### `debug`

- **Type:** `bool`
- **Default:** `false`

Enable or disable building Tauri in debug mode.
See the configuration options and documenation [here](./src/config.ts).

## Advanced Usage

Expand All @@ -61,9 +56,7 @@ export default defineConfig(
mergeConfig(
baseViteConfig,
defineConfig({
plugins: [
tauri()
],
plugins: [tauri()],

// optional but recommended
clearScreen: false,
Expand Down
11 changes: 11 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/** Configuration object for vite-plugin-tauri */
export interface ViteTauriPluginConfig {
/** Enable or disable building Tauri in debug mode. Defaults to `undefined` which means it will be in `debug` mode for `development` and in `release` mode for `production` */
debug?: boolean;
/**
* Specify the rust target to build. Defaults to the target of the currently active toolchain
*
* @see https://doc.rust-lang.org/nightly/rustc/platform-support.html for full list of targets
*/
target?: string;
}
12 changes: 6 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ import { Plugin, ResolvedConfig } from "vite";
import { getTauriConfPath, initTauri } from "./utils";
import TauriCli from "@tauri-apps/cli";
import path, { dirname } from "path";
import { ViteTauriPluginConfig } from "./config";

export function tauri(options?: {
/** Enable or disable building Tauri in debug mode */
debug: boolean;
}): Plugin[] {
export function tauri(config?: ViteTauriPluginConfig): Plugin[] {
let viteConfig: ResolvedConfig;
return [
{
Expand Down Expand Up @@ -48,7 +46,8 @@ export function tauri(options?: {
devPath: `${protocol}://${host}:${port}`,
},
}),
...(options?.debug ? ["--debug"] : []),
...(config?.debug === true ? [] : ["--release"]),
...(config?.target ? ["--target", config.target] : []),
],
"vite-plugin-tauri"
);
Expand Down Expand Up @@ -82,7 +81,8 @@ export function tauri(options?: {
),
},
}),
...(options?.debug ? ["--debug"] : []),
...(config?.debug ? ["--debug"] : []),
...(config?.target ? ["--target", config.target] : []),
],
"vite-plugin-tauri"
);
Expand Down

0 comments on commit cc7b7ab

Please sign in to comment.