admin管理员组文章数量:1289412
I'm trying to create a Firefox extension using Vite. I have 3 inputs:
- popup
- contentScript
- backgroundScript
popup and contentScript both use React (I need to render something with the content script). However, when Vite bundles my code, it creates the jsx runtime in dist/shared/assets and imports this into both popup.js and contentScript.js
This is causing trouble as the contentScript throws the following error:
SyntaxError: import declarations may only appear at top level of a module
If I remove popup from my inputs, the error goes away as contentScript is bundled into a single file. So is there any way I can force vite to created self contained bundles instead of using shared assets for each of my inputs?
This is my Vite config:
import { defineConfig } from "vite";
import { viteStaticCopy } from "vite-plugin-static-copy";
export default defineConfig
(
{
plugins :
[
viteStaticCopy
(
{
targets :
[
{
src: "./manifest.json",
dest: "",
}
]
}
)
],
build :
{
rollupOptions :
{
input :
{
popup : "./popup.html",
content: "./src/content/content.tsx",
background: "./src/background/background.ts"
},
output :
{
entryFileNames: "[name].js",
// manualChunks: undefined,
// chunkFileNames: "[name].js",
// assetFileNames: "[name][extname]"
}
}
},
}
);
I have also tried setting manualChunks to undefined but this did not help so it's commented out for now.
本文标签:
版权声明:本文标题:typescript - How to avoid creating an assets folder for shared dependencies across multiple input files? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741413831a2377390.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论