Skip to content

Commit

Permalink
feat: add option to build with verbose logging
Browse files Browse the repository at this point in the history
  • Loading branch information
amrbashir committed May 7, 2023
1 parent e004cbe commit 417f848
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 32 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Unreleased

- Add option to build with verbose logging
- Fix regression in `3.2.0` where `dev` was always built with `--release` flag and devtools were inaccessible.

# [3.2.0](https://github.com/amrbashir/vite-plugin-tauri/compare/v3.2.0...v3.1.1) (2023-5-6)
Expand Down
2 changes: 2 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ export interface ViteTauriPluginConfig {
* @see https://doc.rust-lang.org/nightly/rustc/platform-support.html for full list of targets
*/
target?: string;
/** Enable or disable verbose logging for the Tauri CLI */
verbose?: boolean;
}
67 changes: 35 additions & 32 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,22 @@ export function tauri(config?: ViteTauriPluginConfig): Plugin[] {
: address.address;
const port = address.port;

TauriCli.run(
[
"dev",
"--config",
JSON.stringify({
build: {
devPath: `${protocol}://${host}:${port}`,
},
}),
...(!config?.debug ? [] : ["--release"]),
...(config?.target ? ["--target", config.target] : []),
],
"vite-plugin-tauri"
);
const args = [
"dev",
"--config",
JSON.stringify({
build: {
devPath: `${protocol}://${host}:${port}`,
},
}),
];

if (config?.debug !== undefined && !config.debug)
args.push("--release");
if (config?.target) args.push("--target", config.target);
if (config?.verbose) args.push("--verbose");

TauriCli.run(args, "vite-plugin-tauri");
});
},
},
Expand All @@ -68,24 +70,25 @@ export function tauri(config?: ViteTauriPluginConfig): Plugin[] {
tauriConfPath = getTauriConfPath();
}

await TauriCli.run(
[
"build",
"--config",
JSON.stringify({
build: {
// at this point, `tauriConfPath` can't be null
distDir: path.relative(
dirname(tauriConfPath!),
path.resolve(viteConfig.build.outDir)
),
},
}),
...(config?.debug ? ["--debug"] : []),
...(config?.target ? ["--target", config.target] : []),
],
"vite-plugin-tauri"
);
const args = [
"build",
"--config",
JSON.stringify({
build: {
// at this point, `tauriConfPath` can't be null
distDir: path.relative(
dirname(tauriConfPath!),
path.resolve(viteConfig.build.outDir)
),
},
}),
];

if (config?.debug) args.push("--debug");
if (config?.target) args.push("--target", config.target);
if (config?.verbose) args.push("--verbose");

await TauriCli.run(args, "vite-plugin-tauri");
},
},
];
Expand Down

0 comments on commit 417f848

Please sign in to comment.