如果脚本是 Web Workers,可以通过添加?worker后缀的方式处理
import Worker from './work.js?worker';
const w = new Worker();
// Vite会转换 work.js 文件为
export default function WorkerWrapper() {
return new Worker("/importassets/work.js?worker_file", {
type: "module",
});
}