diff --git a/plugin/esbuild.config.mjs b/plugin/esbuild.config.mjs index fa58df78..8a802f93 100644 --- a/plugin/esbuild.config.mjs +++ b/plugin/esbuild.config.mjs @@ -69,7 +69,52 @@ let wasmPlugin = { ); }, }; -const context = await esbuild.context({ + +const copyBundle = { + name: "post-compile", + setup(build) { + build.onEnd(async (result) => { + if (prod) { + await fs.promises.copyFile( + "manifest.json", + "build/manifest.json" + ); + return; + } + + if (result.errors.length === 0) { + await copyFiles( + ["manifest.json", ".hotreload"], + "/mnt/c/Users/Andras/Desktop/test/test/.obsidian/plugins/my-plugin" + ); + + await copyFiles( + "build", + "/mnt/c/Users/Andras/Desktop/test/test/.obsidian/plugins/my-plugin" + ); + + await copyFiles( + ["manifest.json", ".hotreload"], + "/mnt/c/Users/Andras/Desktop/test/test2/.obsidian/plugins/my-plugin" + ); + + await copyFiles( + "build", + "/mnt/c/Users/Andras/Desktop/test/test2/.obsidian/plugins/my-plugin" + ); + } + }); + }, +}; + +const cssContext = await esbuild.context({ + entryPoints: ["src/styles.css"], + bundle: true, + outfile: "build/styles.css", + plugins: [copyBundle], +}); + +const jsContext = await esbuild.context({ entryPoints: ["src/plugin.ts"], bundle: true, external: [ @@ -91,6 +136,7 @@ const context = await esbuild.context({ format: "cjs", target: "es2020", logLevel: "info", + resolveExtensions: [".ts"], sourcemap: prod ? false : "inline", treeShaking: false, outfile: "build/main.js", @@ -103,47 +149,13 @@ const context = await esbuild.context({ target: "web", path: "../backend/sync_lib", }), - { - name: "post-compile", - setup(build) { - build.onEnd(async (result) => { - if (prod) { - await fs.promises.copyFile( - "manifest.json", - "build/manifest.json" - ); - } - - if (result.errors.length === 0) { - await copyFiles( - ["manifest.json", "versions.json", ".hotreload"], - "/mnt/c/Users/Andras/Desktop/test/test/.obsidian/plugins/my-plugin" - ); - - await copyFiles( - "build", - "/mnt/c/Users/Andras/Desktop/test/test/.obsidian/plugins/my-plugin" - ); - - await copyFiles( - ["manifest.json", "versions.json", ".hotreload"], - "/mnt/c/Users/Andras/Desktop/test/test2/.obsidian/plugins/my-plugin" - ); - - await copyFiles( - "build", - "/mnt/c/Users/Andras/Desktop/test/test2/.obsidian/plugins/my-plugin" - ); - } - }); - }, - }, + copyBundle, ].filter(Boolean), }); if (prod) { - await context.rebuild(); + await Promise.all([cssContext.rebuild(), jsContext.rebuild()]); process.exit(0); } else { - await context.watch(); + await Promise.all([cssContext.watch(), jsContext.watch()]); } diff --git a/plugin/src/plugin.ts b/plugin/src/plugin.ts index 820dc80f..10f3e383 100644 --- a/plugin/src/plugin.ts +++ b/plugin/src/plugin.ts @@ -1,7 +1,5 @@ import { Editor, MarkdownView, Plugin, WorkspaceLeaf } from "obsidian"; -import "./styles.css"; - import * as lib from "../../backend/sync_lib/pkg/sync_lib.js"; import * as wasmBin from "../../backend/sync_lib/pkg/sync_lib_bg.wasm"; import { SyncSettingsTab } from "./views/settings-tab"; diff --git a/plugin/src/styles.css b/plugin/src/styles.css index 8c650244..7afc4b12 100644 --- a/plugin/src/styles.css +++ b/plugin/src/styles.css @@ -1,12 +1,4 @@ -/* - -This CSS file will be included with your plugin, and -available in the app when your plugin is enabled. - -If your plugin does not need CSS, delete this file. - -*/ - -main { - background-color: brown; +.sync-settings-access-token textarea { + width: 100%; + height: 100px; } diff --git a/plugin/src/views/settings-tab.ts b/plugin/src/views/settings-tab.ts index a8c86403..255b80e5 100644 --- a/plugin/src/views/settings-tab.ts +++ b/plugin/src/views/settings-tab.ts @@ -108,6 +108,7 @@ export class SyncSettingsTab extends PluginSettingTab { new Setting(containerEl) .setName("Access token") + .setClass("sync-settings-access-token") .setDesc( "Set the access token for the server that you can get from the server" )