diff --git a/src/backend/electron/main.ts b/src/backend/electron/main.ts index 390cc69468..73aec90dac 100644 --- a/src/backend/electron/main.ts +++ b/src/backend/electron/main.ts @@ -400,9 +400,6 @@ async function createWindow() { backgroundColor, webPreferences: { preload: path.join(__dirname, "preload.js"), - nodeIntegration: false, - contextIsolation: true, - sandbox: false, // TODO: 外しても問題ないか検証して外す }, icon: path.join(__static, "icon.png"), }); diff --git a/vite.config.mts b/vite.config.mts index 0fd3ea438c..c6bd3ab3ee 100644 --- a/vite.config.mts +++ b/vite.config.mts @@ -82,25 +82,41 @@ export default defineConfig((options) => { }), isElectron && [ cleanDistPlugin(), - electron({ - entry: [ - "./src/backend/electron/main.ts", - "./src/backend/electron/preload.ts", - ], - // ref: https://github.com/electron-vite/vite-plugin-electron/pull/122 - onstart: ({ startup }) => { - if (options.mode !== "test") { - startup([".", "--no-sandbox"]); - } + electron([ + { + entry: "./src/backend/electron/main.ts", + // ref: https://github.com/electron-vite/vite-plugin-electron/pull/122 + onstart: ({ startup }) => { + if (options.mode !== "test") { + startup([".", "--no-sandbox"]); + } + }, + vite: { + plugins: [tsconfigPaths({ root: __dirname })], + build: { + outDir: path.resolve(__dirname, "dist"), + sourcemap, + }, + }, }, - vite: { - plugins: [tsconfigPaths({ root: __dirname })], - build: { - outDir: path.resolve(__dirname, "dist"), - sourcemap, + { + // ref: https://electron-vite.github.io/guide/preload-not-split.html + entry: "./src/backend/electron/preload.ts", + onstart({ reload }) { + reload(); + }, + vite: { + plugins: [tsconfigPaths({ root: __dirname })], + build: { + outDir: path.resolve(__dirname, "dist"), + sourcemap, + rollupOptions: { + output: { inlineDynamicImports: true }, + }, + }, }, }, - }), + ]), ], isBrowser && injectBrowserPreloadPlugin(), ],