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. 47
      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,27 +10,29 @@
<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">
<button <a href="/test" use:link>
type="button" <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" 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"
<svg
class="w-8 h-8 mr-2 -ml-1"
fill="none"
stroke="currentColor"
stroke-width="1.5"
viewBox="0 0 24 24"
xmlns="http://www.w3.org/2000/svg"
aria-hidden="true"
> >
<path <svg
stroke-linecap="round" class="w-8 h-8 mr-2 -ml-1"
stroke-linejoin="round" fill="none"
d="M19 7.5v3m0 0v3m0-3h3m-3 0h-3m-2.25-4.125a3.375 3.375 0 11-6.75 0 3.375 3.375 0 016.75 0zM4 19.235v-.11a6.375 6.375 0 0112.75 0v.109A12.318 12.318 0 0110.374 21c-2.331 0-4.512-.645-6.374-1.766z" stroke="currentColor"
/> stroke-width="1.5"
</svg> viewBox="0 0 24 24"
Create account xmlns="http://www.w3.org/2000/svg"
</button> aria-hidden="true"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M19 7.5v3m0 0v3m0-3h3m-3 0h-3m-2.25-4.125a3.375 3.375 0 11-6.75 0 3.375 3.375 0 016.75 0zM4 19.235v-.11a6.375 6.375 0 0112.75 0v.109A12.318 12.318 0 0110.374 21c-2.331 0-4.512-.645-6.374-1.766z"
/>
</svg>
Create account
</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