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() {