onejs / one

❶ One is a new React framework - target web and native with a single Vite plugin and fully shared code, so you can ship cross-platform nearly as easy as single-platform.
https://onestack.dev
Other
3.39k stars 69 forks source link

Generated app emits warning about importing icon from public directory #220

Open pandeiro opened 4 weeks ago

pandeiro commented 4 weeks ago

In the app produced by the npx one template, running web produces the following warning:

Assets in public directory cannot be imported from JavaScript.
If you intend to import that asset, put the file in the src directory, and use /src/app-icon.png instead of /public/app-icon.png.
If you intend to use the URL of that asset, use /app-icon.png?url.
Files in the public directory are served at the root path.
Instead of /public/app-icon.png, use /app-icon.png.

As a new user of the framework, it's confusing because it sounds like "you're doing it wrong", but maybe there's a reason that you stuck the asset in public instead of somewhere else in the source tree? Changing the example to <Image src="/app-icon.png" ... /> works and gets rid of the warning, but maybe there's a reason not to do that (does it work cross-platform?)

natew commented 1 week ago

Yea I agree this warning is confusing, we'll have to see what is best here. We can move it to src to fix.