tauri-apps/tauri

[bug] "Asset `load_lib.js` not found; fallback to load_lib.js.html" how when i need to import js file ?

Closed this issue · 0 comments

Describe the bug

Asset load_lib.js not found; fallback to load_lib.js.html
am try to import js file an get this

Reproduction

.on_page_load(|window, _page_load_payload| {
            let js_script = "
            if (window.trustedTypes && window.trustedTypes.createPolicy) { // Feature testing
                    window.trustedTypes.createPolicy('default', {
                        createHTML: (string) => DOMPurify.sanitize(string, {RETURN_TRUSTED_TYPE: true}),
                        createScriptURL: string => string, // warning: this is unsafe!
                        createScript: string => string, // warning: this is unsafe!
                    });
                }
                window.resolveLoad = null;
                let done_load_script = new Promise((resolve) => {
                    window.resolveLoad = resolve;
                });
                let script = document.createElement(\"script\");
                script.type = \"module\";
                script.src = \"https://tauri.localhost/load_lib.js\";
                document.head.appendChild(script);
                addEventListener(\"load\", async () => {
                    await done_load_script;
                    try {
                        let script = document.createElement(\"script\");
                        script.type = \"module\";
                        script.src = \"https://tauri.localhost/inject.js\";
                        document.head.appendChild(script);
                    } catch (error) {
                        console.error(error);
                    }
                })
            ";
            window.eval(&js_script).unwrap();
            window.open_devtools();
        })

my files

image

{
  "$schema": "https://schema.tauri.app/config/1",
  "build": {
    "withGlobalTauri": true,
    "devPath": "../src",
    "distDir": "../src"
  },
  "package": {
    "productName": "Youtube Music",
    "version": "0.1.0"
  },
  "tauri": {
    "allowlist": {
      "all": false,
      "shell": {
        "all": false,
        "open": true
      }
    },
    "windows": [
      {
        "title": "Youtube Music",
        "label": "main",
        "url": "https://music.youtube.com/",
        "theme": "Dark",
        "additionalBrowserArgs": "--disable-web-security"
      }
    ],
    "security": {
      "csp": null,
      "dangerousRemoteDomainIpcAccess": [
        {
          "windows": ["main"],
          "domain": "music.youtube.com",
          "enableTauriAPI": true
        }
      ]
    },
    "systemTray": {
      "iconPath": "icons/icon.png",
      "iconAsTemplate": false
    },
    "bundle": {
      "active": true,
      "targets": "all",
      "identifier": "com.thedtvn.ytmusic",
      "icon": [
        "icons/icon.ico",
        "icons/icon.png"
      ]
    }
  }
}

my config

Expected behavior

it import js file to
image

Full tauri info output

[✔] Environment
    - OS: Windows 10.0.22631 X64
    ✔ WebView2: 129.0.2792.52
    ✔ MSVC: Visual Studio Community 2022
    ✔ rustc: 1.79.0 (129f3b996 2024-06-10)
    ✔ cargo: 1.79.0 (ffa9cf99a 2024-06-03)
    ✔ rustup: 1.27.1 (54dd3d00f 2024-04-24)
    ✔ Rust toolchain: stable-x86_64-pc-windows-msvc (environment override by RUSTUP_TOOLCHAIN)
    - node: 20.5.1
    - npm: 9.8.0

[-] Packages
    - tauri [RUST]: 1.8.0
    - tauri-build [RUST]: 1.5.5
    - wry [RUST]: 0.24.11
    - tao [RUST]: 0.16.10
    - tauri-cli [RUST]: 1.6.2
    - @tauri-apps/api : not installed!
    - @tauri-apps/cli [NPM]: 1.6.2

[-] App
    - build-type: bundle
    - CSP: unset
    - distDir: ../src
    - devPath: ../src

Stack trace

No response

Additional context

No response