Browse Source

fix(tauri/examples): fix build errors (#1218)

Noah Klayman 4 years ago
parent
commit
763d027dbb

+ 1 - 1
tauri/examples/api/public/index.html

@@ -9,7 +9,7 @@
 
   <link rel='icon' type='image/png' href='favicon.png'>
   <link rel='stylesheet' href='global.css'>
-  <link rel='stylesheet' href='build/bundle.css'>
+  <!-- <link rel='stylesheet' href='build/bundle.css'> -->
 
   <script defer src='build/bundle.js'></script>
 </head>

+ 17 - 15
tauri/examples/api/rollup.config.js

@@ -16,13 +16,11 @@ export default {
 	},
 	plugins: [
 		svelte({
-			// enable run-time checks when not in production
-			dev: !production,
-			// we'll extract any component CSS out into
-			// a separate file - better for performance
-			css: css => {
-				css.write('public/build/bundle.css');
-			}
+			compilerOptions: {
+				// enable run-time checks when not in production
+				dev: !production
+			},
+			emitCss: false
 		}),
 
 		// If you have external dependencies installed from
@@ -54,18 +52,22 @@ export default {
 };
 
 function serve() {
-	let started = false;
+	let server;
+
+	function toExit() {
+		if (server) server.kill(0);
+	}
 
 	return {
 		writeBundle() {
-			if (!started) {
-				started = true;
+			if (server) return;
+			server = require('child_process').spawn('npm', ['run', 'start', '--', '--dev'], {
+				stdio: ['ignore', 'inherit', 'inherit'],
+				shell: true
+			});
 
-				require('child_process').spawn('npm', ['run', 'start', '--', '--dev'], {
-					stdio: ['ignore', 'inherit', 'inherit'],
-					shell: true
-				});
-			}
+			process.on('SIGTERM', toExit);
+			process.on('exit', toExit);
 		}
 	};
 }

+ 5 - 5
tauri/examples/api/src-tauri/Cargo.lock

@@ -2374,7 +2374,6 @@ dependencies = [
 name = "tauri"
 version = "0.11.1"
 dependencies = [
- "anyhow",
  "async-trait",
  "base64",
  "cfg_aliases",
@@ -2398,7 +2397,6 @@ dependencies = [
 name = "tauri-api"
 version = "0.7.5"
 dependencies = [
- "anyhow",
  "attohttpc",
  "clap",
  "dirs-next",
@@ -2408,7 +2406,6 @@ dependencies = [
  "nfd",
  "notify-rust",
  "once_cell",
- "phf",
  "rand 0.8.3",
  "semver",
  "serde",
@@ -2451,7 +2448,7 @@ dependencies = [
  "serde",
  "serde_json",
  "syn 1.0.60",
- "tauri-api",
+ "tauri-utils",
  "walkdir",
 ]
 
@@ -2459,7 +2456,10 @@ dependencies = [
 name = "tauri-utils"
 version = "0.5.1"
 dependencies = [
- "anyhow",
+ "flate2",
+ "phf",
+ "serde",
+ "serde_json",
  "sysinfo",
  "thiserror",
 ]

+ 1 - 1
tauri/examples/api/src-tauri/src/main.rs

@@ -47,7 +47,7 @@ fn main() {
               // tauri::execute_promise is a helper for APIs that uses the tauri.promisified JS function
               // so you can easily communicate between JS and Rust with promises
               tauri::execute_promise(
-                &mut webview,
+                &mut dispatcher,
                 async move {
                   println!("{} {:?}", endpoint, body);
                   // perform an async operation here

+ 2 - 2
tauri/examples/api/src/App.svelte

@@ -59,8 +59,8 @@
     <div class="tabs">
       {#each views as view}
       <div class="tab">
-        <input type="radio" checked={view.label===selected} />
-        <label class="tabber" on:click={()=> select(view)}>{view.label}</label>
+        <input id={`tab-${view.label}`} type="radio" checked={view.label===selected} />
+        <label for={`tab-${view.label}`} class="tabber" on:click={()=> select(view)}>{view.label}</label>
         <div class="content">
           <svelte:component this={view.component} {onMessage} />
         </div>