Skip to content

Commit

Permalink
build(tauri): resolve build issues
Browse files Browse the repository at this point in the history
  • Loading branch information
4gray committed Nov 16, 2024
1 parent 34ba4aa commit 942b79c
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 6 deletions.
6 changes: 3 additions & 3 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
},
"web": {
"optimization": true,
"outputHashing": "all",
"outputHashing": "none",
"sourceMap": false,
"namedChunks": false,
"aot": true,
Expand All @@ -74,8 +74,8 @@
]
},
"production": {
"optimization": true,
"outputHashing": "all",
"optimization": false,
"outputHashing": "none",
"sourceMap": false,
"namedChunks": false,
"aot": true,
Expand Down
21 changes: 21 additions & 0 deletions src-tauri/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"\>
<plist version="1.0">
<dict>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSExceptionDomains</key>
<dict>
<key>localhost</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSIncludesSubdomains</key>
<true/>
</dict>
</dict>
</dict>
</dict>
</plist>
58 changes: 56 additions & 2 deletions src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,54 @@
}
],
"security": {
"csp": "default-src 'self' 'unsafe-eval' 'unsafe-inline'; media-src *"
"csp": {
"default-src": [
"'self'",
"data:",
"tauri:",
"asset:",
"blob:",
"https:",
"http:",
"'unsafe-eval'",
"'unsafe-inline'"
],
"img-src": [
"'self'",
"data:",
"asset:",
"https:",
"http:",
"blob:"
],
"media-src": ["'self'", "https:", "http:", "blob:", "data:"],
"script-src": [
"'self'",
"'unsafe-inline'",
"'unsafe-eval'",
"tauri:",
"asset:"
],
"style-src": [
"'self'",
"'unsafe-inline'",
"https:",
"http:",
"https://fonts.googleapis.com"
],
"font-src": ["'self'", "https://fonts.gstatic.com", "data:"],
"connect-src": [
"'self'",
"https:",
"http:",
"ws:",
"wss:",
"data:",
"tauri:"
],
"frame-src": ["'self'", "https:", "http:", "blob:", "data:"],
"worker-src": ["'self'", "blob:", "data:"]
}
}
},
"bundle": {
Expand All @@ -34,6 +81,13 @@
"icons/[email protected]",
"icons/icon.icns",
"icons/icon.ico"
]
],
"macOS": {
"entitlements": null,
"exceptionDomain": "*",
"frameworks": [],
"providerShortName": null,
"signingIdentity": null
}
}
}
10 changes: 9 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';

import { AppModule } from './app/app.module';
import { AppConfig } from './environments/environment';

if (AppConfig.production) {
enableProdMode();
}

// Detect if running in Tauri
const isTauri = window && (window as any).__TAURI__;

platformBrowserDynamic()
.bootstrapModule(AppModule, {
preserveWhitespaces: false,
})
.then(() => {
// Only register service worker for web builds
if (!isTauri && 'serviceWorker' in navigator) {
navigator.serviceWorker.register('/ngsw-worker.js');
}
})
.catch((err) => console.error(err));

0 comments on commit 942b79c

Please sign in to comment.