Fix Tauri build

This isn't working, but has some attempts. It's currently blocked, because the built app just has many `ReferenceError: Can't find variable: process`. Something with Webpack isn't building properly, as even trying to just run `webpack serve` from inside yields the same result (I updated webpack, but the problem is in the setup/config, really). I also tried setting `resolve.fallback.process: require.resolve('process/browser')` ([among other things](https://pretagteam.com/question/webpack-5-uncaught-referenceerror-process-is-not-defined)), but the executed code comes from `@padloc/app`, so I'd have to add that package there, and it feels wrong. I'm positive I'm just doing something wrong with the setup, but already spent quite some time on it.

To test, pull this down, run `npm install`, and `npm run tauri:dev` (runs with `webpack` instead of `tauri`, just because the console errors are more useful).

In the process of trying to get this to work, I migrated the icons to the assets directory and updated them. I also tweaked the initial HTML to match the new v4 theme.

Related to #281
This commit is contained in:
Bruno Bernardino 2021-12-27 10:43:39 +00:00
parent fce1f9da30
commit f72e848e65
No known key found for this signature in database
GPG Key ID: D1B0A69ADD114ECE
12 changed files with 1393 additions and 5177 deletions

BIN
assets/app-icon.icns Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 80 KiB

BIN
assets/app-icon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 121 KiB

View File

@ -37,6 +37,7 @@
"start": "npm run pwa:build && lerna run --scope '@padloc/{server,pwa}' --parallel start",
"dev": "lerna run --parallel --scope '@padloc/{server,pwa}' --parallel dev",
"tauri:dev": "lerna run --parallel --scope '@padloc/{server,tauri}' --parallel dev",
"tauri:update": "lerna run update",
"tauri:build": "lerna run build --scope @padloc/tauri",
"repl": "cd packages/server && npm run repl && cd ../..",
"test": "lerna run test",

File diff suppressed because it is too large Load Diff

View File

@ -6,7 +6,9 @@
"scripts": {
"tauri": "tauri",
"build": "tauri build",
"dev": "tauri dev"
"dev:TODO:REPLACE": "tauri dev",
"dev": "webpack serve",
"update": "cd src-tauri && cargo update -p tauri"
},
"author": "",
"license": "ISC",
@ -20,9 +22,9 @@
"ts-loader": "9.2.2",
"ts-node": "10.0.0",
"typescript": "4.4.3",
"webpack": "5.38.1",
"webpack-cli": "4.7.0",
"webpack-dev-server": "3.11.2",
"webpack": "5.52.0",
"webpack-cli": "4.9.1",
"webpack-dev-server": "4.7.1",
"@tauri-apps/cli": "1.0.0-beta.10"
},
"dependencies": {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 118 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 73 KiB

View File

@ -14,7 +14,7 @@
"active": true,
"targets": "all",
"identifier": "app.padloc",
"icon": ["icons/icon.png", "icons/icon.icns", "icons/icon.ico"],
"icon": ["../../../assets/app-icon.png", "../../../assets/app-icon.icns", "../../../assets/app-icon.ico"],
"resources": [],
"externalBin": [],
"copyright": "",

View File

@ -1,21 +1,25 @@
<!DOCTYPE html>
<html>
<head>
<title>Padloc</title>
<title><%= htmlWebpackPlugin.options.title %></title>
<meta charset="UTF-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover"
/>
<meta name="apple-mobile-web-app-capable" content="yes" />
<link rel="shortcut icon" type="image/png" href="/favicon.png" />
<link rel="apple-touch-icon" href="/favicon.png" />
<style>
html,
body {
background: linear-gradient(rgb(89, 198, 255), rgb(7, 124, 185));
background: var(--app-backdrop-background);
color: var(--app-backdrop-color);
width: 100%;
height: 100%;
margin: 0;
overscroll-behavior: none;
color: #fff;
position: fixed;
}

View File

@ -1,6 +1,7 @@
import { Platform } from "@padloc/core/src/platform";
import { WebPlatform } from "@padloc/app/src/lib/platform";
// import { MemoryStorage } from "@padloc/core/src/storage";
export class TauriPlatform extends WebPlatform {
export class TauriPlatform extends WebPlatform implements Platform {
// storage = new MemoryStorage();
}

View File

@ -1,4 +1,4 @@
const { resolve } = require("path");
const { resolve, join } = require("path");
const { EnvironmentPlugin } = require("webpack");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
@ -8,6 +8,7 @@ const out = process.env.PL_PWA_DIR || resolve(__dirname, "dist");
const serverUrl = process.env.PL_SERVER_URL || `http://0.0.0.0:${process.env.PL_SERVER_PORT || 3000}`;
const rootDir = resolve(__dirname, "../..");
const assetsDir = resolve(rootDir, process.env.PL_ASSETS_DIR || "assets");
const { name } = require(join(assetsDir, "manifest.json"));
module.exports = {
entry: resolve(__dirname, "src/index.ts"),
@ -58,12 +59,14 @@ module.exports = {
}),
new CleanWebpackPlugin(),
new HtmlWebpackPlugin({
title: "Padloc",
title: name,
template: resolve(__dirname, "src/index.html"),
}),
],
devServer: {
contentBase: resolve(__dirname, "dist"),
static: {
directory: resolve(__dirname, "dist"),
},
historyApiFallback: true,
host: "0.0.0.0",
port: process.env.PL_PWA_PORT || 8080,