Skip to content

Commit

Permalink
ドキュメント足したりの変更
Browse files Browse the repository at this point in the history
  • Loading branch information
Hiroshiba committed Oct 28, 2024
1 parent d80b4d6 commit cc9fb82
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
12 changes: 6 additions & 6 deletions .vscode/launch.template.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@
"configurations": [
{
"name": "Attach to Renderer Process",
// NOTE: background.tsで指定しているremote-debugging-port
"port": 9222,
"port": 9222, // NOTE: background.tsで指定しているremote-debugging-port
"request": "attach",
"type": "chrome",
"webRoot": "${workspaceFolder}/src",
"resolveSourceMapLocations": [
"${workspaceFolder}/**",
"!**/node_modules/**"
"${workspaceFolder}/**",
"!**/node_modules/**"
],
"timeout": 20000, // 20 * 1000 ms程度あればビルド時間は間に合うはず
},
Expand All @@ -31,8 +30,9 @@
"type": "node"
},
{
// 直接Electronのみを起動し、バックグラウンドで"electron:serve"を実行する
// NOTE: ホットリロードできない代わりに、デバッグ起動が軽い
"name": "Launch Electron Main Process without hot reload",
// Electronのみを起動
"request": "launch",
"type": "node",
"runtimeExecutable": "npx",
Expand All @@ -41,7 +41,6 @@
".",
"--no-sandbox"
],
// 事前にElectronを起動せずにバックグラウンドで"electron:serve"を実行する
"preLaunchTask": "Electron Serve without Launch Electron",
"skipFiles": [
"<node_internals>/**"
Expand All @@ -68,6 +67,7 @@
"stopAll": true
},
{
// ホットリロードできない代わりにデバッグ起動が軽いモード
"name": "Launch Electron Main/Renderer without hot reload",
"configurations": [
"Attach to Renderer Process",
Expand Down
3 changes: 1 addition & 2 deletions .vscode/tasks.template.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Electron Serve without Launch Electron",
// Electronを起動せずにバックグラウンドで"electron:serve"を実行する
// NOTE: デバッグ起動を軽くできる
"type": "npm",
"script": "electron:serve",
"options": {
Expand Down
14 changes: 9 additions & 5 deletions vite.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export default defineConfig((options) => {
);
}

const shouldEmitSourcemap = ["development", "test"].includes(options.mode);
// 型を曖昧にして下の[process.platform]のエラーを回避する
const sevenZipBinNames: Record<string, string> = {
win32: "7za.exe",
Expand All @@ -42,11 +41,16 @@ export default defineConfig((options) => {
? path.join(__dirname, "build", "vendored", "7z") + path.sep
: "") + sevenZipBinName;
process.env.VITE_APP_VERSION = process.env.npm_package_version;

const shouldEmitSourcemap = ["development", "test"].includes(options.mode);
const sourcemap: BuildOptions["sourcemap"] = shouldEmitSourcemap
? "inline"
: false;
const launchEditor =
process.env.SKIP_LAUNCH_ELECTRON !== "1" && options.mode !== "test";

// ref: electronの起動をスキップしてデバッグ起動を軽くする
const skipLahnchElectron =
options.mode === "test" || process.env.SKIP_LAUNCH_ELECTRON === "1";

return {
root: path.resolve(__dirname, "src"),
envDir: __dirname,
Expand Down Expand Up @@ -90,7 +94,7 @@ export default defineConfig((options) => {
// ref: https://github.com/electron-vite/vite-plugin-electron/pull/122
onstart: ({ startup }) => {
console.log("main process build is complete.");
if (launchEditor) {
if (skipLahnchElectron) {
void startup([".", "--no-sandbox"]);
}
},
Expand All @@ -106,7 +110,7 @@ export default defineConfig((options) => {
// ref: https://electron-vite.github.io/guide/preload-not-split.html
entry: "./src/backend/electron/preload.ts",
onstart({ reload }) {
if (launchEditor) {
if (skipLahnchElectron) {
reload();
}
},
Expand Down

0 comments on commit cc9fb82

Please sign in to comment.