Skip to content

Commit 40adc34

Browse files
committed
Set up Vite template
1 parent d6b4ae3 commit 40adc34

25 files changed

+2446
-13
lines changed

.cargo/config.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
[build]
1+
[target.'cfg(not(target_arch = "wasm32"))']
22
rustflags = ["-C", "target-cpu=native"]
33

4+
[target.wasm32-unknown-unknown]
5+
rustflags = ["--cfg", 'getrandom_backend="wasm_js"']
6+
47
[alias]
58
mlog = "run --release --features mlog --bin mlog --"
69
mlogv32 = "run --release --features mlogv32 --bin mlogv32 --"

.gitignore

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,25 @@
1-
/target
1+
/target/
22
*.json.gz
3+
4+
# Logs
5+
logs/
6+
*.log
7+
npm-debug.log*
8+
yarn-debug.log*
9+
yarn-error.log*
10+
pnpm-debug.log*
11+
lerna-debug.log*
12+
13+
node_modules/
14+
dist/
15+
pkg/
16+
*.local
17+
18+
# Editor directories and files
19+
.idea/
20+
.DS_Store
21+
*.suo
22+
*.ntvs*
23+
*.njsproj
24+
*.sln
25+
*.sw?

.prettierrc

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
11
{
2-
"tabWidth": 4
3-
}
2+
"tabWidth": 2,
3+
"overrides": [
4+
{
5+
"files": ["*.json"],
6+
"options": {
7+
"tabWidth": 4
8+
}
9+
}
10+
],
11+
"plugins": ["@trivago/prettier-plugin-sort-imports"]
12+
}

.vscode/settings.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,8 @@
77

88
// "rust-analyzer.cargo.noDefaultFeatures": true,
99
// "rust-analyzer.cargo.features": ["no_std", "serde_alloc"]
10-
"rust-analyzer.cargo.features": "all"
10+
"rust-analyzer.cargo.features": "all",
11+
12+
"eslint.workingDirectories": ["mindy-website/www"],
13+
"prettier.prettierPath": "mindy-website/www/node_modules/prettier"
1114
}

Cargo.lock

Lines changed: 55 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "mindy"
33
version = "0.1.0"
44
edition = "2024"
5-
rust-version = "1.88"
5+
rust-version.workspace = true
66

77
[[bin]]
88
name = "mlog"
@@ -140,3 +140,11 @@ strip = false
140140
[profile.bench]
141141
debug = true
142142
strip = false
143+
144+
[workspace]
145+
members = [
146+
"mindy-website",
147+
]
148+
149+
[workspace.package]
150+
rust-version = "1.88"

mindy-website/Cargo.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[package]
2+
name = "mindy-website"
3+
edition = "2024"
4+
rust-version.workspace = true
5+
6+
[lib]
7+
crate-type = ["cdylib"]
8+
9+
[dependencies]
10+
console_error_panic_hook = "0.1.7"
11+
getrandom = { version = "0.3.3", features = ["wasm_js"] }
12+
mindy = { path = "..", features = ["embedded_graphics"] }
13+
wasm-bindgen = "0.2.100"
14+
wee_alloc = "0.4.5"

mindy-website/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# mindy-website
2+
3+
## Running
4+
5+
Install `wasm-pack`: https://drager.github.io/wasm-pack/installer/
6+
7+
```sh
8+
rustup target add wasm32-unknown-unknown
9+
wasm-pack build
10+
11+
cd www
12+
yarn
13+
yarn dev
14+
```

mindy-website/src/lib.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
use wasm_bindgen::prelude::*;
2+
3+
#[global_allocator]
4+
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
5+
6+
#[wasm_bindgen]
7+
extern "C" {
8+
fn alert(s: &str);
9+
}
10+
11+
#[wasm_bindgen]
12+
pub fn init() {
13+
console_error_panic_hook::set_once();
14+
}
15+
16+
#[wasm_bindgen]
17+
pub fn greet() {
18+
alert("Hello world!");
19+
}

mindy-website/www/eslint.config.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import js from "@eslint/js";
2+
import reactDom from "eslint-plugin-react-dom";
3+
import reactHooks from "eslint-plugin-react-hooks";
4+
import reactRefresh from "eslint-plugin-react-refresh";
5+
import reactX from "eslint-plugin-react-x";
6+
import { globalIgnores } from "eslint/config";
7+
import globals from "globals";
8+
import tseslint from "typescript-eslint";
9+
10+
export default tseslint.config([
11+
globalIgnores(["dist"]),
12+
{
13+
files: ["**/*.{ts,tsx}"],
14+
extends: [
15+
js.configs.recommended,
16+
...tseslint.configs.recommendedTypeChecked,
17+
...tseslint.configs.stylisticTypeChecked,
18+
reactHooks.configs["recommended-latest"],
19+
reactRefresh.configs.vite,
20+
reactX.configs["recommended-typescript"],
21+
reactDom.configs.recommended,
22+
],
23+
languageOptions: {
24+
parserOptions: {
25+
project: ["./tsconfig.node.json", "./tsconfig.app.json"],
26+
tsconfigRootDir: import.meta.dirname,
27+
},
28+
ecmaVersion: 2020,
29+
globals: globals.browser,
30+
},
31+
},
32+
]);

0 commit comments

Comments
 (0)