From 94924c5a73366c4ca9fa88a27d4a2005d2e15a05 Mon Sep 17 00:00:00 2001 From: sabonerune <102559104+sabonerune@users.noreply.github.com> Date: Sat, 11 May 2024 21:05:17 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20sandbox=E3=82=92=E6=9C=89=E5=8A=B9?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/electron/main.ts | 3 --- vite.config.mts | 47 ++++++++++++++++++++++++------------ 2 files changed, 31 insertions(+), 19 deletions(-) diff --git a/src/backend/electron/main.ts b/src/backend/electron/main.ts index 1889dee3ec..63edb176a1 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..9facc3df44 100644 --- a/vite.config.mts +++ b/vite.config.mts @@ -82,25 +82,40 @@ 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, + { + 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(), ],