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

Vite wrong file path with debug mode #151

Closed
xesjkeee opened this issue Apr 9, 2022 · 2 comments
Closed

Vite wrong file path with debug mode #151

xesjkeee opened this issue Apr 9, 2022 · 2 comments

Comments

@xesjkeee
Copy link

xesjkeee commented Apr 9, 2022

Hey, thanks for the partytown!

After some time of usage, I faced with the error:

My vite.config.ts

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'
import { partytownVite } from '@builder.io/partytown/utils'

export default defineConfig({
    plugins: [
        partytownVite({
            dest: path.join(__dirname, 'dist', 'partytown')
        }),
        vue(),
        // ...
    ]
})

index.html

<!DOCTYPE html>
<html lang="en">
  <head>
    <!-- meta elements -->
  
    <script>
      partytown = {
        debug: true,
        lib: '/partytown/'
      }
    </script>
    <script src="/partytown/partytown.js"></script>

    <script type="text/partytown">
        // analytics script
     </script>
  </head>
  <body>
    <div id="app"></div>
    <script type="module" src="/src/main.ts"></script>
  </body>
</html>

While partytown.debug == false there are all good, but when I set true, I get the error in the devtools:

GET https://localhost:8080/partytown/debug/partytown-sandbox-sw.js?v=0.5.2 net::ERR_ABORTED 404 (Not Found)

Let's open this link in the new tab, and yeah – "Page not found", but if I remove query params from the link ?v=0.5.2 and try to go again, I'll get the needed file

img

@xesjkeee
Copy link
Author

xesjkeee commented Apr 9, 2022

Thanks for @Fl0pZz, his PR should fix it

Just copied his fixes directly to node_modules/@builder.io/partytown/utils/index.cjs to check it, and I got successfully working vite-server with partytown:

img

img

img

@adamdbradley
Copy link
Contributor

Should be fixed with d2f6840

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

No branches or pull requests

2 participants