-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* feat(cli/templates) add `vanilla-ts` * refactor(cli/fragments) vanilla-ts Readme.md * refactor(cli/fragments) Removed useless app.css in vanilla-ts template * refactor(cli/fragments) Moved tauri logo to the middle and renamed _[pnpm-yarn-npm]_package.json to package.json for vanilla-ts template * refactor(cli/fragments) Created a vite-env.d.ts with tauri api types for vanilla-ts template
- Loading branch information
Showing
15 changed files
with
223 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"create-tauri-app": "minor" | ||
"create-tauri-app-js": "minor" | ||
--- | ||
|
||
Add `vanilla-ts` templates. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
packages/cli/fragments/fragment-vanilla-ts/.vscode/extensions.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"recommendations": ["tauri-apps.tauri-vscode", "rust-lang.rust-analyzer"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Tauri + Vanilla TS | ||
|
||
This template should help get you started developing with Tauri in vanilla HTML, CSS and Typescript. | ||
|
||
## Recommended IDE Setup | ||
|
||
- [VS Code](https://code.visualstudio.com/) + [Tauri](https://marketplace.visualstudio.com/items?itemName=tauri-apps.tauri-vscode) + [rust-analyzer](https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-analyzer) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
beforeDevCommand = {{pkg_manager_run_command}} dev | ||
beforeBuildCommand = {{pkg_manager_run_command}} build | ||
devPath = http://localhost:1420 | ||
distDir = ../dist | ||
withGlobalTauri = true | ||
|
||
[files] | ||
tauri.svg = src/assets/tauri.svg | ||
vite.svg = src/assets/vite.svg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
pnpm-debug.log* | ||
lerna-debug.log* | ||
|
||
node_modules | ||
dist | ||
dist-ssr | ||
*.local | ||
|
||
# Editor directories and files | ||
.vscode/* | ||
!.vscode/extensions.json | ||
.idea | ||
.DS_Store | ||
*.suo | ||
*.ntvs* | ||
*.njsproj | ||
*.sln | ||
*.sw? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<link rel="stylesheet" href="/src/style.css" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Tauri App</title> | ||
<script type="module" src="/src/main.ts" defer></script> | ||
<style> | ||
.logo.vite:hover { | ||
filter: drop-shadow(0 0 2em #747bff); | ||
} | ||
|
||
.logo.typescript:hover { | ||
filter: drop-shadow(0 0 2em #2d79c7); | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
<div class="container"> | ||
<h1>Welcome to Tauri!</h1> | ||
|
||
<div class="row"> | ||
<a href="https://vitejs.dev" target="_blank"> | ||
<img src="/src/assets/vite.svg" class="logo vite" alt="Vite logo" /> | ||
</a> | ||
<a href="https://tauri.app" target="_blank"> | ||
<img | ||
src="/src/assets/tauri.svg" | ||
class="logo tauri" | ||
alt="Tauri logo" | ||
/> | ||
</a> | ||
<a href="https://www.typescriptlang.org/docs" target="_blank"> | ||
<img | ||
src="/src/assets/typescript.svg" | ||
class="logo typescript" | ||
alt="typescript logo" | ||
/> | ||
</a> | ||
</div> | ||
|
||
<p>Click on the Tauri logo to learn more about the framework</p> | ||
|
||
<div class="row"> | ||
<div> | ||
<input id="greet-input" placeholder="Enter a name..." /> | ||
<button type="button" onclick="greet()">Greet</button> | ||
</div> | ||
</div> | ||
|
||
<p id="greet-msg"></p> | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "{{package_name}}", | ||
"private": true, | ||
"version": "0.0.0", | ||
"type": "module", | ||
"scripts": { | ||
"dev": "vite", | ||
"build": "tsc && vite build", | ||
"preview": "vite preview", | ||
"tauri": "tauri" | ||
}, | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"@tauri-apps/api": "^1.0.2", | ||
"@tauri-apps/cli": "^1.0.5", | ||
"vite": "^3.0.2", | ||
"typescript": "^4.8.2" | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
packages/cli/fragments/fragment-vanilla-ts/src/assets/typescript.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
const { invoke } = window.__TAURI__; | ||
|
||
let greetInputEl: HTMLInputElement | null; | ||
let greetMsgEl: HTMLElement | null; | ||
|
||
window.addEventListener("DOMContentLoaded", () => { | ||
greetInputEl = document.querySelector("#greet-input"); | ||
greetMsgEl = document.querySelector("#greet-msg"); | ||
}); | ||
|
||
async function greet() { | ||
if (greetMsgEl && greetInputEl) { | ||
greetMsgEl.textContent = await invoke("greet", { | ||
name: greetInputEl.value, | ||
}); | ||
} | ||
} | ||
|
||
window.greet = greet; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import type * as TauriApiTypes from "@tauri-apps/api"; | ||
|
||
declare global { | ||
interface Window { | ||
__TAURI__: typeof TauriApiTypes; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "ESNext", | ||
"module": "ESNext", | ||
"lib": ["ESNext", "DOM"], | ||
"moduleResolution": "Node", | ||
"strict": true, | ||
"sourceMap": true, | ||
"resolveJsonModule": true, | ||
"esModuleInterop": true, | ||
"types": ["vite/client"], | ||
"noEmit": true, | ||
"noUnusedLocals": true, | ||
"noUnusedParameters": true, | ||
"noImplicitReturns": true | ||
}, | ||
"include": ["./src"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { defineConfig } from "vite"; | ||
|
||
// https://vitejs.dev/config/ | ||
export default defineConfig({ | ||
// Vite optons tailored for Tauri development and only applied in `tauri dev` or `tauri build` | ||
// prevent vite from obscuring rust errors | ||
clearScreen: false, | ||
// tauri expects a fixed port, fail if that port is not available | ||
server: { | ||
port: 1420, | ||
strictPort: true, | ||
}, | ||
// to make use of `TAURI_DEBUG` and other env variables | ||
// https://tauri.studio/v1/api/config#buildconfig.beforedevcommand | ||
envPrefix: ["VITE_", "TAURI_"], | ||
build: { | ||
// Tauri supports es2021 | ||
target: ["es2021", "chrome100", "safari13"], | ||
// don't minify for debug builds | ||
minify: !process.env.TAURI_DEBUG ? "esbuild" : false, | ||
// produce sourcemaps for debug builds | ||
sourcemap: !!process.env.TAURI_DEBUG, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters