-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
怎样在dist-electron下生成其他js文件? #243
Comments
我也遇到同样的问题,目前还没有找到解决方案,如果找到了麻烦相互告知下,谢谢 |
可以参考下我的这个,希望对你有用。https://github.com/mundane799699/electron-vite-project |
我看了你的这个配置是在entry里面引入了文件, |
|
你可以参考下这个vite插件 https://github.com/think-flow/l4d2addon_installer/blob/main/vite.plugin.modulePath.ts import workerPath from './worker?modulePath'
ipcMain.handle("query-db", () => {
return new Promise((resolve, reject) => {
const worker = new Worker(workerPath);
......
});
}); |
|
electron/main.ts:
electron/worker.ts:
启动后调用query-db方法发现报错:Error occurred in handler for 'query-db': Error: Cannot find module 'D:\project\VsCodeProjects\red-archive\dist-electron\worker.js'
at Module._resolveFilename (node:internal/modules/cjs/loader:1055:15)
at Module._load (node:internal/modules/cjs/loader:908:27)
at c._load (node:electron/js2c/node_init:2:13672)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:96:12)
at MessagePort. (node:internal/main/worker_thread:186:26)
at [nodejs.internal.kHybridDispatch] (node:internal/event_target:807:20)
at exports.emitMessage (node:internal/per_context/messageport:23:28) {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
那么怎样才可以让worker.js出现在dist-electron目录下面呢?
The text was updated successfully, but these errors were encountered: