Closed xbears closed 7 months ago
It's being applied because content scripts are built using library mode during development. If you only want to apply it during the dev command, you'll have to manually choose when it's applied. Something like this should work fine:
vite: ({ command }) => ({
plugins: [
command === "dev" ? Obfusticator() : [],
],
}),
But if it doesn't work in development, I doubt it will work in production...
The CLI is reporting some kind of error, but I can't figure out what they are since the obfuscation plugin doesn't support source maps, and the error message is swallowed. I also can't log anything in the service worker when running the dev command, and none of the logs I'd expect to see are printed. I imagine the obfustication plugin is also responsible for that somehow, but I didn't look into it too much.
Can confirm, the production build of the extension doesn't work either. So I don't know what's going on... I would just recommend not using the plugin and relying on the default minification settings for now. I won't have time to debug this any further today, and the plugin doesn't make it easy. So yeah, this will probably be in limbo for a while.
Thank you very much for your reply, I tried switching to the rollup plugin rollup-plugin-obfuscator
and it seems to work fine.
https://www.npmjs.com/package/rollup-plugin-obfuscator
import Obfusticator from 'rollup-plugin-obfuscator'
vite: ({ command }) => ({
plugins: [
command === "serve" ? [] : Obfusticator(),
],
}),
Ok, glad you found one that works!
Describe the bug
Enabling the vite obfuscator plugin in wxt causes the content script to not work.
I found that the vite plugin in wxt with
apply:'build'
configured was still being run with pnpm dev, There are no issues with this vite plugin and works just fine in normal vite projects.To Reproduce
wxt-test.zip
pnpm i
pnpm dev
Screenshots
https://github.com/wxt-dev/wxt/assets/650444/a92cbcf3-fbc8-4ec2-bced-760de4211690
Environment