-
Notifications
You must be signed in to change notification settings - Fork 155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
/public
directory configuration, and module.scss
#99
Comments
Well, scss module imports will work if next compiler option added into "types": ["vite/client"], Looks like there is declarations of |
|
in renderer, use public assets , must be |
SCSS
Miss that, because after project was created and initialized, i just put my app into renderer dir, completeley replacing it's content.
Ok, got you, my ide is vscode. Anyway issue has been resolved, and now i know two ways to deal with that. /public
It doesn't work like that. Even your link says:
It works only if i put my The problem is that built app couldn't find files from |
Or, you said about usage of public assets? |
try set browser window |
It seems you don't really understand |
another way: #36 |
this repo use public dir |
May be. Lets synchronize on this. My understanding of public assets is:
Ok, but how is that differs? Aint those assets should be shiped as is? As it works in vite?
As i did.
I wouldn't do this because all assets in my project lives in public directory, and i don't think it will be ever changed.
Yes it has been putted to /out/renderer. But in build app it doesn't work. As i already said, in dev environment evrything fine.
Guy there using fetch api to get his public asset. It's a little bit different case. Ok, check this one, i've create clean project from solid-ts template with command: pnpm create @quick-start/electron my-app --template solid-ts Then add Make my app component very trivial: export function App()
{
return <img src="/gem.jpg" />
} it just directly uses jpg from public assets. Then, run my app wtih Ok, work so far. Then, i build app with /out directory looks like this: But, if i run my app, it will look like this: Picture is lost. And this is a problem. Because public assets won't show up. Here is test repo with this app. https://github.com/jakerdy/vite-electron-MissingPublicAssets Ok, i might not understand something, but not so much. |
This should be a problem with the In <img src="/logo.svg" alt="logo" /> But in // public assets
<img src={new URL('/logo.svg', import.meta.url).href} alt="logo" /> |
Hm. Ok, going to ask @ryansolid about this... |
Thanks for helping with that! |
In vue and react, it will be bundle to |
I'm a bit late for this party, but the correct answer isn`t here to find. What you really need to do is this:
https://vitejs.dev/config/shared-options.html#base Vite will rewrite all public-paths while building to this base and it will work like a charm. The reason why it works in dev-mode and not in the production-build is following: With the base-path |
Describe the bug
Hi!
I ve trying to port my web app to Electron. Your project looks great and suit my needs pretty well, but i couldn't figure out couple things.
First: Way to handle
/public
directory which should ships 'as is' without modifications.With "vanilla" vite, '/public' dir in root of my project has been working with
"./public"
invite.conf.js
. Also it works for both dev and release modes.Where should i put it, and how should it be configured?
I have tried root of project next to
tsconfig.js
, also did put in into/src/renderer/public
, but it won't work out of the box.Also it won't work if i add
"./public"
into renderer vite config, with both directory placements.It works in dev (not build) only if i set path in tsconfig like this:
path.join(__dirname, "public")
.Is this intended way of doing this? Searching docs gives me 0 results.
Second: I am using Sass, and import all my styles as modules from files called like "StyleName.module.scss".
In "vanilla" vite it just works, but with vite-electron it says:
Cannot find module './StyleName.module.scss' or its corresponding type declarations.
.For now i created file
src/renderer/typings.d.ts
withdeclare module "*.module.scss";
but it feels wrong.What is proper way to handle it?
Thoug i sami-fixed those issues, and make my 'dev' setup working. But when i trying to build shiping version of my app. I got just black screen with errors that says
Failed to load resource: net::ERR_FILE_NOT_FOUND
. Which clearly means that something wrong with/public
directory.All of this pretty frustrating because i don't know how to resolve it my self, even dont know where to start from.
electron-vite great, hope, you could help me with this.
And, if you could, please explain why all that stuff works in "vanilla" vite and doesn't work here, i think it will greatly improve my understanding of how electron-vite works.
Electron-Vite Version
^1.0.17
Electron Version
^21.3.3
Vite Version
^4.0.4
Validations
The text was updated successfully, but these errors were encountered: