From 099036de242f39c8c796efee79172452d3ca0557 Mon Sep 17 00:00:00 2001 From: sechan100 Date: Sun, 2 Feb 2025 15:58:00 +0900 Subject: [PATCH] =?UTF-8?q?build:=20=ED=98=84=EC=9E=AC=20=EB=B9=8C?= =?UTF-8?q?=EB=93=9C=20=EB=AA=A8=EB=93=9C=EC=97=90=20=EB=8C=80=ED=95=9C=20?= =?UTF-8?q?=ED=94=8C=EB=9E=98=EA=B7=B8=EB=A5=BC=20=EC=A0=84=EC=97=AD?= =?UTF-8?q?=EB=B3=80=EC=88=98=EC=97=90=20=EC=B6=94=EA=B0=80=ED=95=98?= =?UTF-8?q?=EA=B3=A0,=20=EC=9D=B4=EC=97=90=20=EB=94=B0=EB=9D=BC=20?= =?UTF-8?q?=EA=B0=9C=EB=B0=9C=EC=97=90=20=ED=95=84=EC=9A=94=ED=95=9C=20?= =?UTF-8?q?=EB=8F=84=EA=B5=AC=EB=93=A4=EC=9D=84=20=ED=99=9C=EC=84=B1?= =?UTF-8?q?=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- esbuild.config.mjs | 17 +++++++++-------- src/main.ts | 10 ++++++++-- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/esbuild.config.mjs b/esbuild.config.mjs index 87c07d2..f42b25d 100644 --- a/esbuild.config.mjs +++ b/esbuild.config.mjs @@ -13,9 +13,9 @@ if you want to view the source, please visit the github repository of this plugi */ `; -const development = process.argv[2] === "development"; -const local = process.argv[2] === "local"; -const prod = process.argv[2] === "production"; +const isDevelopment = process.argv.includes("dev"); +const isLocal = process.argv.includes("local"); +const isProd = process.argv.includes("production"); // CSS를 하나로 합치기 위한 rename 플러그인 const renamePlugin = { @@ -60,18 +60,18 @@ const context = await esbuild.context({ ...builtins, ], define: { - 'process.env.NODE_ENV': JSON.stringify(development || local || prod) + 'process.env.NODE_ENV': isDevelopment ? '"development"' : '"production"', }, format: "cjs", // CommonJS 포맷 target: "es2018", logLevel: "warning", - sourcemap: prod ? false : "inline", + sourcemap: isProd ? false : "inline", treeShaking: true, outfile: "main.js", // JavaScript 번들 파일 plugins: [ renamePlugin, // CSS 파일 이름 변경 플러그인 ], - minify: prod, + minify: isProd, loader: { ".tsx": "tsx", // TypeScript와 TSX 파일을 처리 ".ts": "ts", @@ -81,10 +81,11 @@ const context = await esbuild.context({ write: true, }); -if(prod) { + +if(isProd) { await context.rebuild(); process.exit(0); -} else if(local) { +} else if(isLocal) { await context.rebuild(); console.log("\n === 클라우드로 플러그인 복사 시작 ==="); await copyPluginFilesTo_iCloud(); diff --git a/src/main.ts b/src/main.ts index da246ab..0f7b4a2 100644 --- a/src/main.ts +++ b/src/main.ts @@ -38,9 +38,15 @@ export default class DailyRoutinePlugin extends Plugin { activateView(DailyRoutineObsidianView.VIEW_TYPE, 1); } }); - // this.app.emulateMobile(!this.app.isMobile); + + process.env.NODE_ENV === "development" && this.addRibbonIcon( + "toggle-left", + "Toggle Mobile View", + // @ts-ignore + () => this.app.emulateMobile(!this.app.isMobile) + ); - setTimeout(() => activateView(DailyRoutineObsidianView.VIEW_TYPE, 1), 0); + setTimeout(() => activateView(DailyRoutineObsidianView.VIEW_TYPE, 1), 500); } onunload() {