Skip to content
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

Compatibility with SvelteKit #1200

Open
jerrygreen opened this issue Feb 13, 2024 · 1 comment
Open

Compatibility with SvelteKit #1200

jerrygreen opened this issue Feb 13, 2024 · 1 comment

Comments

@jerrygreen
Copy link

Is your feature request related to a problem? Please describe.
Is there compatibility with SvelteKit? I found these instructions on Stackoverflow but it seems outdated:

Instructions look cool except they don't work: they seem to be for Svelte not SvelteKit.

Describe the solution you'd like
I'd like to have some info in docs how to run Neutralino with the SvelteKit sample app.

Describe alternatives you've considered
I tried to figure out how to merge both of them, but it's seems untrivial since I'm new with Neutralino. I happen to make SvelteKit work with Electron but this ain't helping to figure out Neutralino.

@jerrygreen
Copy link
Author

jerrygreen commented Feb 14, 2024

After a few hours tinkering, I figured out how to:

  1. Make it work for dev environment where the loading url is vite server like http://localhost:5173/
  2. Make it work for production, bundling everything into statics and accesing it through locally placed index.html

It required a lot of tricks, like most notable one from this comment #909 (comment):

import authInfo from '../.tmp/auth_info.json'
if (import.meta.env.DEV) {
  const {accessToken, port} = authInfo
  window.NL_PORT = port
  window.NL_TOKEN = accessToken
  window.NL_ARGS = [
    'bin\\neutralino-win_x64.exe',
    '',
    '--load-dir-res',
    '--path=.',
    '--export-auth-info',
    '--neu-dev-extension',
    '--neu-dev-auto-reload',
    '--window-enable-inspector'
  ]
}
window.Neutralino.init()

Because by some reason, global variables aren't set in use-cases like using SvelteKit.

It kinda works now but I have to figure out how to separate these two things, development environment and production.
Of course, I could manually change url inside neutralino.config.json but it's not practical.

neu cli doesn't let me override these settings, though I figured I could use the binaries directly like described here in docs:

But when I try to run neutralino-win_x64.exe (I'm on windows), with --config-file, I'm getting this error:

neutralino-dev.config.json file is missing or corrupted.

But it's not missing nor corrupted. It's an exact copy of neutralino.config.dev – which completely fine and works with neu but when I use the binaries directly, it doesn't work. Issue that seems to be around a few years here, unfortunately:

A little help from maintainers would be appreciated. How to communicate different version of config to neu cli or to neutralino binaries, properly?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant