Skip to content

🎨 Frontend is now automatically built #52

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from
Open
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
3,974 changes: 2,428 additions & 1,546 deletions package-lock.json

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@
"eslint-plugin-n": "^16.3.1",
"eslint-plugin-prettier": "^5.0.1",
"eslint-plugin-promise": "^6.1.1",
"postcss": "^8.4.24",
"postcss-discard-comments": "^6.0.0",
"postcss": "^8.5.3",
"postcss-discard-comments": "^7.0.4",
"prettier": "3.1.0",
"sass": "^1.56.1",
"sass": "^1.89",
"terser": "^5.39.2",
"typescript": "^4.6.4",
"vite": "^3.2.3"
"vite": "^6.3.5"
},
"dependencies": {
"@tauri-apps/api": "^2.2.0",
Expand Down
26 changes: 24 additions & 2 deletions src-tauri/build.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
use std::process::Command;
use std::{process::Command, time::Duration};

fn main() {
#[cfg(windows)]
pub const NPM: &str = "npm.cmd";
#[cfg(not(windows))]
pub const NPM: &str = "npm";

fn main() -> Result<(), Box<dyn std::error::Error>> {
if let Some((commit_date, commit_hash)) = Command::new("git")
.args(["rev-parse", "--short", "HEAD"])
.output()
Expand All @@ -22,5 +27,22 @@ fn main() {
println!("cargo:rustc-env=GIT_COMMIT_INFO={commit_hash} {commit_date}");
}

println!("cargo::rerun-if-changed=dist");
println!("cargo::rerun-if-changed=../src");

if !tauri_build::is_dev() {
let duration = std::fs::metadata("dist/index.html")
.and_then(|m| m.modified())
.map(|time| time.elapsed().unwrap_or(Duration::MAX));
if duration.is_err()
|| duration
.as_ref()
.is_ok_and(|duration| duration > &Duration::from_secs(30))
{
Command::new(NPM).args(["run", "build"]).output()?;
}
}

tauri_build::build();
Ok(())
}
6 changes: 5 additions & 1 deletion src-tauri/src/commands/pty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ pub async fn pty_open(
.profiles
.iter()
.find(|profile| profile.uuid == profile_uuid)
.ok_or(PtyError::UnknownPty)?;
.ok_or_else(|| {
PtyError::Creation(String::from(
"There is no profile corresponding to this ID.",
))
})?;

ptys.0.write().await.insert(
uuid,
Expand Down
1 change: 1 addition & 0 deletions src-tauri/src/settings/deserialized.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ pub struct Settings {
pub webkit_compositing_mode: bool,

#[serde(skip_serializing)]
#[allow(dead_code)]
theme: String,
}

Expand Down
6 changes: 3 additions & 3 deletions src/style/components/view/common.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@import "pane";
@import "view";
@use "pane";
@use "view";

@import "widgets/base";
@use "widgets/base";

@counter-style base36 {
system: fixed;
Expand Down
2 changes: 1 addition & 1 deletion src/style/components/view/widgets/base.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import "terminal";
@use "terminal";

.widget {
position: relative;
Expand Down
22 changes: 11 additions & 11 deletions src/style/style.scss
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
@import "variables";
@use "variables";

@import "animations/tab";
@import "animations/popup";
@import "animations/toast";
@import "animations/common";
@use "animations/tab";
@use "animations/popup";
@use "animations/toast";
@use "animations/common";

@import "ui/titlebar";
@use "ui/titlebar";

@import "components/interface/toast";
@import "components/interface/popup";
@import "components/interface/tab";
@import "components/view/common";
@use "components/interface/toast" as *;
@use "components/interface/popup" as *;
@use "components/interface/tab" as *;
@use "components/view/common" as *;

@import "../../node_modules/@xterm/xterm/css/xterm.css";
@use "../../node_modules/@xterm/xterm/css/xterm.css";

@font-face {
font-family: "Inter";
Expand Down
26 changes: 24 additions & 2 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,39 @@ export default defineConfig({
envPrefix: ["VITE_", "TAURI_"],
build: {
target: ["es2021", "chrome100", "safari13"],
minify: !process.env.TAURI_DEBUG ? "esbuild" : false,
minify: !process.env.TAURI_DEBUG ? "terser" : false,
sourcemap: !!process.env.TAURI_DEBUG,
outDir: "../src-tauri/dist",
terserOptions: {
compress: {
drop_console: true,
drop_debugger: true,
ecma: 2018,
passes: 2,
unsafe: true,
hoist_funs: true,
hoist_vars: true,
keep_fargs: false,
pure_getters: true,
pure_new: true,
unsafe_arrows: true,
unsafe_math: true,
unsafe_proto: true,
},
},
rollupOptions: {
output: {
assetFileNames: "[hash:4][extname]",
},
},
},
root: "./src",
css: {
preprocessorOptions: {
scss: {
additionalData:
process.platform === "linux"
? '@import "./target/linux.scss";'
? '@use "./target/linux.scss";'
: "",
},
},
Expand Down