Skip to content

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

@sleeyax

Description

@sleeyax

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions