crxjs / chrome-extension-tools

Bundling Chrome Extensions can be pretty complex. It doesn't have to be.
https://crxjs.dev/vite-plugin
2.98k stars 192 forks source link

crxjs does not support HTTPS flag in vite #852

Open kaminskypavel opened 11 months ago

kaminskypavel commented 11 months ago

Build tool

Vite

Where do you see the problem?

Describe the bug

I have a content-script running on a https website, settings https flag on vite config is being ignored.

Reproduction

in vite.config.ts

  server: {
    https: true,   <--------------
    port: 5173,
    hmr: {
      clientPort: 5173
    },
    proxy: {
      '/api': {
        target: 'http://localhost:3010',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, ''),
      },
    },
  },
})

and results in an error

Service worker registration failed. Status code: 3

"background": {
"service_worker": "service-worker-loader.js",
"type": "module"
},

I believe this has to do with the encoded value in plugin-background.ts

if you can confirm this is the case i don't mind submitting a PR

Logs

No response

System Info

System:
    OS: Windows 11
    CPU: (16) x64 Intel(R) Core(TM) i7-10870H CPU @ 2.20GHz
    Memory: 41 GB / 63 GB
  Binaries:
    Node: 20.7.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.19 - C:\Program Files\nodejs\yarn.CMD
    npm: 10.1.0 - C:\Program Files\nodejs\npm.CMD
    pnpm: 8.12.0 - ~\AppData\Local\pnpm\pnpm.EXE
  Browsers:
    Edge: Chromium (120.0.2210.91)

Severity

blocking an upgrade

kaminskypavel commented 10 months ago

@jacksteamdev if you'd like to guide me a bit here, I can take a shot at this issue

Qchuanwudi commented 4 months ago

I know how to solve it