adding ng-app-web target

pull/19/head
Niko 2 years ago
parent 6cb63220c7
commit cf8f8d35bd
  1. 1
      ng-app-native/.gitignore
  2. 3
      ng-app-native/package.json
  3. 10
      ng-app-native/pnpm-lock.yaml
  4. 25
      ng-app-native/src/lib/Greet.svelte
  5. 7
      ng-app-native/src/routes/Home.svelte
  6. 2
      ng-app-native/src/routes/Test.svelte
  7. 9
      ng-app-native/vite.config.ts

@ -9,6 +9,7 @@ lerna-debug.log*
node_modules
dist
dist-web
dist-ssr
*.local

@ -5,6 +5,8 @@
"type": "module",
"scripts": {
"dev": "vite",
"webdev": "cross-env NG_APP_WEB=1 TAURI_DEBUG=1 vite",
"webbuild": "cross-env NG_APP_WEB=1 vite build",
"build": "vite build",
"preview": "vite preview",
"check": "svelte-check --tsconfig ./tsconfig.json",
@ -24,6 +26,7 @@
"@tsconfig/svelte": "^3.0.0",
"@types/node": "^18.7.10",
"autoprefixer": "^10.4.14",
"cross-env": "^7.0.3",
"internal-ip": "^7.0.0",
"postcss": "^8.4.23",
"postcss-load-config": "^4.0.1",

@ -9,6 +9,7 @@ specifiers:
'@types/node': ^18.7.10
autoprefixer: ^10.4.14
classnames: ^2.3.2
cross-env: ^7.0.3
flowbite: ^1.6.5
flowbite-svelte: ^0.37.1
internal-ip: ^7.0.0
@ -37,6 +38,7 @@ devDependencies:
'@tsconfig/svelte': 3.0.0
'@types/node': 18.16.13
autoprefixer: 10.4.14_postcss@8.4.23
cross-env: 7.0.3
internal-ip: 7.0.0
postcss: 8.4.23
postcss-load-config: 4.0.1_postcss@8.4.23
@ -557,6 +559,14 @@ packages:
resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==}
dev: true
/cross-env/7.0.3:
resolution: {integrity: sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw==}
engines: {node: '>=10.14', npm: '>=6', yarn: '>=1'}
hasBin: true
dependencies:
cross-spawn: 7.0.3
dev: true
/cross-spawn/7.0.3:
resolution: {integrity: sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==}
engines: {node: '>= 8'}

@ -1,21 +1,30 @@
<script lang="ts">
import { invoke } from "@tauri-apps/api/tauri"
let name = "";
let greetMsg = ""
let greetMsg = "";
let ng;
if (import.meta.env.NG_APP_WEB) {
ng = {
greet: async function (n) {
return "greetings from web " + n;
},
};
} else {
import("@tauri-apps/api/tauri").then((tauri) => {
ng = { greet: (n) => tauri.invoke("greet", { name: n }) };
});
}
async function greet(){
async function greet() {
// Learn more about Tauri commands at https://tauri.app/v1/guides/features/command
greetMsg = await invoke("greet", { name })
greetMsg = await ng.greet(name);
}
</script>
<div>
<div class="row">
<input id="greet-input" placeholder="Enter a name..." bind:value={name} />
<button on:click={greet}>
Greet
</button>
<button on:click={greet}> Greet </button>
</div>
<p>{greetMsg}</p>
</div>

@ -1,3 +1,8 @@
<script>
import { Button } from "flowbite-svelte";
import { link } from "svelte-spa-router";
</script>
<main class="container2">
<div class="row">
<img src="/nextgraph.svg" class="logo block h-40" alt="NextGraph Logo" />
@ -5,6 +10,7 @@
<h1 class="text-2xl mb-10">Welcome to NextGraph</h1>
<div class="row">
<a href="/test" use:link>
<button
type="button"
class="text-white bg-primary-700 hover:bg-primary-700/90 focus:ring-4 focus:outline-none focus:ring-primary-700/50 font-medium rounded-lg text-lg px-5 py-2.5 text-center inline-flex items-center dark:focus:ring-primary-700/55 mr-2 mb-2"
@ -26,6 +32,7 @@
</svg>
Create account
</button>
</a>
</div>
<div class="row mt-10">
<button

@ -2,7 +2,7 @@
import Greet from "../lib/Greet.svelte";
</script>
<main class="container">
<main class="container2">
<h1>Welcome to test</h1>
<div class="row">

@ -24,21 +24,22 @@ export default defineConfig(async () => {
clearScreen: false,
// tauri expects a fixed port, fail if that port is not available
server: {
port: 1420,
port: process.env.NG_APP_WEB ? 1421 : 1420,
host: '0.0.0.0',
strictPort: true,
hmr: {
protocol: 'ws',
host,
port: 5183,
port: process.env.NG_APP_WEB ? 5184 : 5183,
},
},
// to make use of `TAURI_DEBUG` and other env variables
// https://tauri.studio/v1/api/config#buildconfig.beforedevcommand
envPrefix: ["VITE_", "TAURI_"],
envPrefix: ["VITE_", "TAURI_", "NG_"],
build: {
outDir: process.env.NG_APP_WEB ? 'dist-web' : 'dist',
// Tauri supports es2021
target: process.env.TAURI_PLATFORM == "windows" ? "chrome105" : "safari13",
target: process.env.NG_APP_WEB ? 'modules' : process.env.TAURI_PLATFORM == "windows" ? "chrome105" : "safari13",
// don't minify for debug builds
minify: !process.env.TAURI_DEBUG ? "esbuild" : false,
// produce sourcemaps for debug builds

Loading…
Cancel
Save