Repository: DioxusLabs/dioxus (language: rust)

Issue:
PWA example is broken
**Problem**

The below entry in `Dioxus.toml` causes everything from under `<PROJECT_ROOT>/public` to be copied under `<BUILD_ROOT>/assets` instead of `<BUILD_ROOT>/`:

```conf
[application]
asset_dir = "public"
```

The official [PWA example](https://github.com/DioxusLabs/dioxus/tree/main/examples/pwa) is now broken. It's `index.html` includes links to `/sw.js`, `manifest.json`, but since both of them are under `<PROJECT_ROOT>/public`, they become available under `<PROJECT_ROOT>/assets`. Upon


**Steps To Reproduce**

Steps to reproduce the behavior:

- open the Network tab in developer tools of the browser
- run `dx serve`, 
- navigate to http://localhost:8080
- inspect the responses to `sw.js`, `favicon.ico`, `manifes.json`
  - they all return the same content as index.html, since the server cannot find the requested resources

**Expected behavior**

Static assets should be deployed to `<BUILD_ROOT>/`.

Preferred fix:
- copy the contents of `asset_dir` to `<BUILD_ROOT>/`

Optional step:
- create a new entry in `Dioxus.toml`, e.g. `asset_dir_dest` which points to `<BUILD_ROOT>/` by default, but can be overridden

**Screenshots**

![Image](https://github.com/user-attachments/assets/e87471af-46b4-41ca-844b-7cb08cb509e2)

![Image](https://github.com/user-attachments/assets/901bdf74-1328-4f9f-81fb-5395bbe49e79)

![Image](https://github.com/user-attachments/assets/a225a17a-0fc4-469d-92e9-5e56bffbe754)

**Environment:**
 - Dioxus version:  v0.6.2
 - Rust version:    rustc 1.84.0 (9fc6b4312 2025-01-07)
 - OS info:         Linux
 - App platform:    `web`

**Questionnaire**
<!-- If you feel up to the challenge, please uncomment one of the lines below: -->

<!-- I'm interested in fixing this myself but don't know where to start -->
<!-- I would like to fix and I have a solution -->
<!-- I don't have time to fix this right now, but maybe later -->



Discussion / hints:

Fix patch:
diff --git a/examples/pwa/index.html b/examples/pwa/index.html
index 44bfa59cc4..d78d643d5f 100644
--- a/examples/pwa/index.html
+++ b/examples/pwa/index.html
@@ -1,30 +1,18 @@
 <!DOCTYPE html>
 <html>
-<head>
-  <title>{app_title}</title>
-  <script>
-    if ('serviceWorker' in navigator) {
-      navigator.serviceWorker.register(
-        '/sw.js'
-      );
-    }
-  </script>
-  <link rel="manifest" href="manifest.json">
-  <meta content="text/html;charset=utf-8" http-equiv="Content-Type" />
-  <meta name="viewport" content="width=device-width, initial-scale=1">
-  <meta charset="UTF-8" />
-  {style_include}
-</head>
-<body>
-  <div id="main"></div>
-  <script type="module">
-    import init from "/{base_path}/assets/dioxus/{app_name}.js";
-    init("/{base_path}/assets/dioxus/{app_name}_bg.wasm").then(wasm => {
-      if (wasm.__wbindgen_start == undefined) {
-        wasm.main();
+  <head>
+    <title>{app_title}</title>
+    <script>
+      if ("serviceWorker" in navigator) {
+        navigator.serviceWorker.register("/{base_path}/assets/sw.js");
       }
-    });
-  </script>
-  {script_include}
-</body>
-</html>
\ No newline at end of file
+    </script>
+    <link rel="manifest" href="/assets/manifest.json" />
+    <meta content="text/html;charset=utf-8" http-equiv="Content-Type" />
+    <meta name="viewport" content="width=device-width, initial-scale=1" />
+    <meta charset="UTF-8" />
+  </head>
+  <body>
+    <div id="main"></div>
+  </body>
+</html>
diff --git a/examples/pwa/public/manifest.json b/examples/pwa/public/manifest.json
index ef542899dd..ad7cd4f422 100644
--- a/examples/pwa/public/manifest.json
+++ b/examples/pwa/public/manifest.json
@@ -31,4 +31,4 @@
   "dir": "ltr",
   "lang": "en",
   "orientation": "portrait"
-}
\ No newline at end of file
+}


Test patch: