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

Uncaught SyntaxError: Invalid or unexpected token error logged to console #81

Open
sleeyax opened this issue Jun 15, 2024 · 0 comments
Open
Labels
bug Something isn't working

Comments

@sleeyax
Copy link
Owner

sleeyax commented Jun 15, 2024

When using electron-forge + Vite + asarmor I can see the following error logged to the devtools console:

Uncaught SyntaxError: Invalid or unexpected token

The app still works fine though, this is a visual annoyance at best and a minor performance degradation at worst.


This happens because the browser still tries to load any encrypted assets defined in the output .vite/rendere/main_window/index.html:

    <!-- ... -->
    <script type="module" crossorigin src="./assets/index.js"></script>
    <link rel="stylesheet" crossorigin href="./assets/index.css">

Because this file is loaded here, right before decrypting the render process:

mainWindow.loadFile(path.join(__dirname, `../renderer/${MAIN_WINDOW_VITE_NAME}/index.html`));

Removing the render script from the root index.html:

    <!-- ... -->
    <script type="module" src="/src/renderer.ts"></script>`

... doesn't resolve the issue because then Vite no longer picks it up for processing and we end up with a different error.

Thus, we should figure out a way to tell Vite to include these source files but not output them to .vite/rendere/main_window/index.html.

@sleeyax sleeyax added the bug Something isn't working label Jun 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant