Skip to content

Commit b14eae3

Browse files
committed
add sss-web-app
1 parent 08fcd33 commit b14eae3

31 files changed

Lines changed: 1786 additions & 4 deletions

.github/workflows/pages.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: Release to Github Pages
2+
3+
on:
4+
push:
5+
tags:
6+
- "p*.*.*"
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: write
11+
pages: write
12+
id-token: write
13+
14+
concurrency:
15+
group: "pages"
16+
cancel-in-progress: false
17+
18+
jobs:
19+
Github-Pages-Release:
20+
timeout-minutes: 10
21+
22+
environment:
23+
name: github-pages
24+
url: ${{ steps.deployment.outputs.page_url }}
25+
26+
runs-on: ubuntu-latest
27+
28+
steps:
29+
- uses: actions/checkout@v4 # repo checkout
30+
31+
- name: Install nightly Rust
32+
uses: dtolnay/rust-toolchain@stable
33+
with:
34+
components: clippy, rustfmt
35+
36+
- name: Add WASM target
37+
run: rustup target add wasm32-unknown-unknown
38+
39+
- name: lint
40+
run: cargo clippy & cargo fmt
41+
42+
# If using tailwind...
43+
# - name: Download and install tailwindcss binary
44+
# run: npm install -D tailwindcss && npx tailwindcss -i <INPUT/PATH.css> -o <OUTPUT/PATH.css> # run tailwind
45+
46+
- name: Download and install Trunk binary
47+
run: wget -qO- https://github.com/trunk-rs/trunk/releases/download/v0.21.7/trunk-x86_64-unknown-linux-gnu.tar.gz | tar -xzf-
48+
49+
- name: Build with Trunk
50+
# "${GITHUB_REPOSITORY#*/}" evaluates into the name of the repository
51+
# using --public-url something will allow trunk to modify all the href paths like from favicon.ico to repo_name/favicon.ico .
52+
# this is necessary for github pages where the site is deployed to username.github.io/repo_name and all files must be requested
53+
# relatively as favicon.ico. if we skip public-url option, the href paths will instead request username.github.io/favicon.ico which
54+
# will obviously return error 404 not found.
55+
run: ./trunk build --release --features csr --public-url "${GITHUB_REPOSITORY#*/}"
56+
57+
# Deploy to gh-pages branch
58+
# - name: Deploy 🚀
59+
# uses: JamesIves/github-pages-deploy-action@v4
60+
# with:
61+
# folder: dist
62+
63+
# Deploy with Github Static Pages
64+
65+
- name: Setup Pages
66+
uses: actions/configure-pages@v4
67+
with:
68+
enablement: true
69+
# token:
70+
71+
- name: Upload artifact
72+
uses: actions/upload-pages-artifact@v2
73+
with:
74+
# Upload dist dir
75+
path: "./dist"
76+
77+
- name: Deploy to GitHub Pages 🚀
78+
id: deployment
79+
uses: actions/deploy-pages@v3

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ target/
55

66
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
77
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
8-
Cargo.lock
8+
**/Cargo.lock
99

1010
# These are backup files generated by rustfmt
1111
**/*.rs.bk
@@ -15,7 +15,8 @@ Cargo.lock
1515

1616
# Added by cargo
1717

18-
/target
18+
**/target
19+
**/dist
1920

2021
# macos
2122
.DS_Store

Cargo.toml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ members = [
55
"sss-lib/sss-core",
66
"sss-lib/sss-std",
77
"sss-cli",
8-
"layouts-derive"]
8+
"layouts-derive",
9+
"sss-web-app"
10+
]
911
resolver = "2"
1012

1113
[workspace.package]
@@ -49,7 +51,7 @@ opt-level = 'z'
4951
debug = false
5052
lto = true
5153
codegen-units = 24
52-
panic = 'unwind'
54+
panic = 'abort'
5355
strip = true
5456
incremental = true
5557
debug-assertions = false
@@ -62,3 +64,9 @@ debug = true
6264
[profile.bench]
6365
opt-level = 3
6466
debug = false
67+
68+
[profile.wasm-release]
69+
inherits = "release"
70+
opt-level = 'z'
71+
lto = true
72+
codegen-units = 1

rust-toolchain.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[toolchain]
2+
channel = "stable" # test change

sss-web-app/Cargo.toml

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
[package]
2+
name = "sss-web-app"
3+
version.workspace = true
4+
edition.workspace = true
5+
authors.workspace = true
6+
repository.workspace = true
7+
license.workspace = true
8+
9+
[lib]
10+
crate-type = ["cdylib", "rlib"]
11+
12+
13+
[dependencies]
14+
leptos = {git="https://github.com/sjud/leptos" }
15+
leptos_meta = {git="https://github.com/sjud/leptos" }
16+
leptos_router = { git="https://github.com/sjud/leptos" }
17+
leptos_axum = { git="https://github.com/sjud/leptos", default-features = false, optional = true }
18+
console_log = "1"
19+
log = "0.4"
20+
base64_light.workspace = true
21+
sss_core = { path = "../sss-lib/sss-core" }
22+
sss_std = { path = "../sss-lib/sss-std" }
23+
render = { path = "../sss-lib/render" }
24+
toml.workspace = true
25+
wasm-bindgen-futures = { version = "0.4" }
26+
serde = { workspace = true, features = ["derive"] }
27+
getrandom = { version = "0.2", features = ["js"] }
28+
# ssr
29+
console_error_panic_hook = { version = "0.1"}
30+
axum = { version = "0.7", default-features = false, optional = true }
31+
tokio = { workspace = true, features = ["rt-multi-thread"], optional = true }
32+
wasm-bindgen = { version = "0.2" }
33+
web-sys = { version = "0.3", features = [
34+
"Document", "Window", "Navigator", "Clipboard", "Request", "Response","RequestInit",
35+
] }
36+
axum-js-fetch = {git = "https://github.com/seanaye/axum-js-fetch", optional = true}
37+
tower = {version = "0.5", optional = true}
38+
http = { version = "1.0", optional = true }
39+
40+
[features]
41+
csr = [
42+
"leptos/csr",
43+
]
44+
45+
hydrate = [
46+
"leptos/hydrate",
47+
]
48+
ssr = [
49+
"dep:axum",
50+
"dep:tokio",
51+
"dep:http",
52+
"dep:axum-js-fetch",
53+
"dep:tower",
54+
"leptos/ssr",
55+
"leptos_axum/wasm",
56+
"leptos_meta/ssr",
57+
"leptos_router/ssr",
58+
]
59+
60+
61+
[dev-dependencies]
62+
sss-web-app = {path = ".", features = [ "hydrate", "ssr" ] }
63+
leptos_axum = { git="https://github.com/sjud/leptos", features = ["wasm"], default-features = false }
64+
65+
[package.metadata.trunk]
66+
target = "index.html"
67+
release = false
68+
dist = "dist"
69+
public_url = "/"
70+
filehash = true
71+
inject_scripts = true
72+
73+
[package.metadata.trunk.serve]
74+
addresses = ["127.0.0.1"]
75+
port = 3000
76+
open = false
77+
[package.metadata.trunk.tools]
78+
tailwindcss = "4.0.0"
79+
80+
[package.metadata.leptos]
81+
output-name = "sss-web-app"
82+
site-root = "target/site"
83+
site-pkg-dir = "pkg"
84+
style-file = "style/main.scss"
85+
assets-dir = "public"
86+
site-addr = "127.0.0.1:3000"
87+
reload-port = 3001
88+
browserquery = "defaults"
89+
# DEV || PROD
90+
env = "DEV"
91+
bin-features = ["ssr"]
92+
bin-default-features = false
93+
lib-features = ["hydrate"]
94+
lib-default-features = false
95+
lib-profile-release = "wasm-release"
96+
97+
98+
[package.metadata.cargo-all-features]
99+
skip_feature_sets = [["csr", "ssr"], ["csr", "hydrate"], ["ssr", "hydrate"]]
100+
denylist = ["axum", "tower", "http", "leptos_axum", "hyper"]

sss-web-app/Makefile.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
extend = [
2+
{ path = "../cargo-make/main.toml" },
3+
{ path = "../cargo-make/deno-build.toml" },
4+
]
5+
6+
[env]
7+
8+
CLIENT_PROCESS_NAME = "deno"

sss-web-app/deno.jsonc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"tasks": {
3+
"build:server": "wasm-pack build --release --target web --out-name server --features ssr --no-default-features",
4+
"build:client": "wasm-pack build --release --target web --out-name client --features hydrate --no-default-features",
5+
"build": "deno task build:server & deno task build:client",
6+
"start": "deno run --allow-read --allow-net run.ts",
7+
},
8+
}

sss-web-app/index.html

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<link data-trunk rel="tailwind-css" href="public/styles.scss" />
5+
6+
<link data-trunk rel="icon" href="public/favicon.ico" />
7+
8+
<link
9+
data-trunk
10+
rel="rust"
11+
data-wasm-opt="z"
12+
data-bin="sss-web-app"
13+
data-weak-refs
14+
/>
15+
</head>
16+
17+
<body></body>
18+
</html>

sss-web-app/public/favicon.ico

169 KB
Binary file not shown.

sss-web-app/public/styles.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@import "tailwindcss";

0 commit comments

Comments
 (0)