adding ng-app-web target

Niko 2 years ago
parent 29091a387b
commit ea6d7e86f1
  1. 1
      ng-app-native/.gitignore
  2. 3
      ng-app-native/package.json
  3. 10
      ng-app-native/pnpm-lock.yaml
  4. 23
      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 node_modules
dist dist
dist-web
dist-ssr dist-ssr
*.local *.local

@ -5,6 +5,8 @@
"type": "module", "type": "module",
"scripts": { "scripts": {
"dev": "vite", "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", "build": "vite build",
"preview": "vite preview", "preview": "vite preview",
"check": "svelte-check --tsconfig ./tsconfig.json", "check": "svelte-check --tsconfig ./tsconfig.json",
@ -24,6 +26,7 @@
"@tsconfig/svelte": "^3.0.0", "@tsconfig/svelte": "^3.0.0",
"@types/node": "^18.7.10", "@types/node": "^18.7.10",
"autoprefixer": "^10.4.14", "autoprefixer": "^10.4.14",
"cross-env": "^7.0.3",
"internal-ip": "^7.0.0", "internal-ip": "^7.0.0",
"postcss": "^8.4.23", "postcss": "^8.4.23",
"postcss-load-config": "^4.0.1", "postcss-load-config": "^4.0.1",

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

@ -1,21 +1,30 @@
<script lang="ts"> <script lang="ts">
import { invoke } from "@tauri-apps/api/tauri"
let name = ""; 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 // Learn more about Tauri commands at https://tauri.app/v1/guides/features/command
greetMsg = await invoke("greet", { name }) greetMsg = await ng.greet(name);
} }
</script> </script>
<div> <div>
<div class="row"> <div class="row">
<input id="greet-input" placeholder="Enter a name..." bind:value={name} /> <input id="greet-input" placeholder="Enter a name..." bind:value={name} />
<button on:click={greet}> <button on:click={greet}> Greet </button>
Greet
</button>
</div> </div>
<p>{greetMsg}</p> <p>{greetMsg}</p>
</div> </div>

@ -1,3 +1,8 @@
<script>
import { Button } from "flowbite-svelte";
import { link } from "svelte-spa-router";
</script>
<main class="container2"> <main class="container2">
<div class="row"> <div class="row">
<img src="/nextgraph.svg" class="logo block h-40" alt="NextGraph Logo" /> <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> <h1 class="text-2xl mb-10">Welcome to NextGraph</h1>
<div class="row"> <div class="row">
<a href="/test" use:link>
<button <button
type="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" 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> </svg>
Create account Create account
</button> </button>
</a>
</div> </div>
<div class="row mt-10"> <div class="row mt-10">
<button <button

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

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

Loading…
Cancel
Save