You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For Tauri v2, in rust code, and only when running in dev, the app.asset_resolver object have no assets (iter over them yields nothing). However in production, the application assets are correctly listed.
In particular, the localhost plugin does not work in dev
Reproduction
$ npm create tauri-app@latest -- --beta
> npx
> create-tauri-app --beta
✔ Project name · tauri_app_test
✔ Choose which language to use for your frontend · TypeScript / JavaScript - (pnpm, yarn, npm, bun)
✔ Choose your package manager · npm
✔ Choose your UI template · Vanilla
✔ Choose your UI flavor · TypeScript
✔ Would you like to setup the project for mobile as well? · no
Template created! To get started run:
cd tauri_app_test
npm install
npm run tauri dev
$ cd tauri_app_test
$ npm install
$ sed -i s/com.tauri.dev/test-app.example.org/ src-tauri/tauri.conf.json
create assets:
$ mkdir -p public
$ touch public/public-asset.js src/src-asset.js
// Prevents additional console window on Windows in release, DO NOT REMOVE!!#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]// Learn more about Tauri commands at https://tauri.app/v1/guides/features/command#[tauri::command]fngreet(name:&str) -> String{format!("Hello, {}! You've been greeted from Rust!", name)}fnmain(){
tauri::Builder::default().plugin(tauri_plugin_shell::init()).invoke_handler(tauri::generate_handler![greet]).setup(|app| {let asset_resolver = app.asset_resolver();println!("asset list start");for asset in asset_resolver.iter(){println!("asset: {}", asset.0);}println!("asset list stop");Ok(())}).run(tauri::generate_context!()).expect("error while running tauri application");}
Running npm run tauri dev:
asset list start
asset list stop
In the DOM inspector, network tab, both assets are loaded fine though
Running npm run tauri build followed by running the built executable ./src-tauri/target/release/tauri_app_test:
asset list start
asset: /assets/index-0M1iEA7z.js
asset: /index.html
asset: /public-asset.js
asset: /assets/index-XlHJ6GfY.css
asset list stop
src-asset.js is not there, but if we configure rollup to load this asset it will appear, in vite.config.js, set:
import{defineConfig}from"vite";// https://vitejs.dev/config/exportdefaultdefineConfig(async()=>({// Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build`//// 1. prevent vite from obscuring rust errorsclearScreen: false,// 2. tauri expects a fixed port, fail if that port is not availableserver: {port: 1420,strictPort: true,watch: {// 3. tell vite to ignore watching `src-tauri`ignored: ["**/src-tauri/**"],},},build: {rollupOptions: {input: {index: './index.html',src_asset: 'src/src-asset.js',}}}}));
Now, running the built app, it shows the asset:
asset list start
asset: /public-asset.js
asset: /assets/index-XlHJ6GfY.css
asset: /index.html
asset: /assets/src_asset-BSKcq9xs.js
asset: /assets/index-0M1iEA7z.js
asset list stop
I am running a HTTP webserver in rust, triggered from the javascript side, and aimed at serving files for the system browser in order to print them. I need those assets to be served to this web server like the localhost plugin. This is to workaround the lack of print options in Tauri (and WebkitGtk). The app I am working on is : https://github.com/mildred/web_docs
The text was updated successfully, but these errors were encountered:
Describe the bug
For Tauri v2, in rust code, and only when running in dev, the app.asset_resolver object have no assets (iter over them yields nothing). However in production, the application assets are correctly listed.
In particular, the localhost plugin does not work in dev
Reproduction
create assets:
update
index.html
to include both assets:in
src/main.rs
:Running
npm run tauri dev
:In the DOM inspector, network tab, both assets are loaded fine though
Running
npm run tauri build
followed by running the built executable./src-tauri/target/release/tauri_app_test
:src-asset.js
is not there, but if we configure rollup to load this asset it will appear, invite.config.js
, set:Now, running the built app, it shows the asset:
Expected behavior
same assets shown for dev and for build
Full
tauri info
outputStack trace
No response
Additional context
I am running a HTTP webserver in rust, triggered from the javascript side, and aimed at serving files for the system browser in order to print them. I need those assets to be served to this web server like the localhost plugin. This is to workaround the lack of print options in Tauri (and WebkitGtk). The app I am working on is : https://github.com/mildred/web_docs
The text was updated successfully, but these errors were encountered: