Open devidw opened 1 year ago
This is something with Vite itself not the plugin. I worked around by adding build.modulePreload = false
in my vite.config.ts
@Whoaa512 thank you so much for this contribution works in my project with "vite": "^5.2.11",
! Maybe we could add it to the docs and close the thread. Where should we put it? Here https://crxjs.dev/vite-plugin/concepts/content-scripts?
It wasn't enough for my setup with Vite 4.4.5 to just modulePreload = false
. Vite was still adding a preloader function with preloading a single CSS file. The only way to remove it was to remove the whole vite:build-import-analysis
plugin:
function viteDisablePlugins(list: string[]): Plugin {
return {
name: 'vite-disable-plugins',
configResolved(config) {
const pls: Plugin[] = config.plugins as any;
list.forEach(torem => {
const idx = pls.findIndex(pl => pl.name === torem);
idx >= 0 && pls.splice(idx, 1);
})
},
}
}
export default defineConfig(({ command }) => ({
plugins: [
viteDisablePlugins(['vite:build-import-analysis']),
]
}))
Ok, im using the newest "vite": "^5.2.11",
Build tool
Vite
Where do you see the problem?
Describe the bug
I have got a content script with something like:
content script content.ts
On build, this generates into:
Here, the last two paths are problematic, since they are tried to be loaded from the website the content scripts run on.
Which results in them not being found:
However, removing the extra paths and putting an empty array into the generated files does work, the extension seems to work without these available.
Reproduction
https://github.com/devidw/crxjs-issue
Seems to be in combination with other package imports that let the tooling generate these helper files like
_commonjsHelpers
.In this example, importing
extpay
, without this, there are no such helper files generated and no loading problems.However, trying to get things working with such imports.
Thanks a lot 🙏
Logs
System Info
Severity
annoyance