xwberry_obsidian-drag-out/esbuild.config.mjs
xberry1231 9b76d70473
Add Drag Out Obsidian plugin for native drag-and-drop (#1)
* docs: add README for Drag Out plugin with installation, usage, and notes

* build(esbuild): add esbuild config for bundling main.ts

Add configuration to bundle main.ts with environment‑aware settings,
minify in production, generate source maps in dev, and watch for changes.
Excludes external modules and builtins.

* build(main-orig.js): add CommonJS build of main.ts as plugin entry point

* build(main.js): add esbuild-generated bundle for Drag Out plugin

* feat(main.ts): add DragOut plugin for external file drag support

Add DragOutPlugin class with settings, dragstart handling, icon resolution,
and a setting tab. Enables dragging files/folders from Obsidian to external
applications using a configurable modifier key. Includes debug logging and
cross‑platform support.

* feat: add manifest.json for Drag Out plugin to define metadata and versioning

* chore(package): add package.json with project metadata and build scripts

* chore(release): add release.mjs to automate version sync and build

Adds a script that reads the package version, updates manifest.json and
runs the production build, and copies release artifacts into dist/<version>/.
for GitHub releases.

* build: add tsconfig.json to configure TypeScript compiler settings

* feat: add icon.png and versions.json for app branding and version tracking

* remove original handwritten main.js pre-esbuild

* docs(license): adds license boilerplate

* docs(changelog): add initial changelog file with 0.1.2 entries

* docs(readme): add Bun build note and correct formatting

Add a note that build scripts rely on Bun, update code block language to
text, fix indentation of bullet points, and adjust line breaks for
consistency.

* refactor(main.js): update minified bundle variable names and improve drag handling logic

* refactor(DragOutPlugin): improve drag handling and selection logic
- Move event suppression after startDrag to avoid early exit
- Simplify selected path extraction with Array.from/map/filter
- Ensure current item is added only if not already selected
- Reorder comments for clarity and maintainability

* refactor(release): separate optional and required files, abort on missing required files

This change updates the release script to treat `icon.png` as an optional asset.
Missing required files now trigger an error and halt the release, while missing optional files only emit a warning.

* docs(changelog): update change notes for platform defaults, drag behavior, README, and icon fallback

- Make default modifier key platform‑aware (Ctrl on Windows/Linux, Alt on macOS).
- Clarify multi‑select drag behavior: selected items drag all, unselected drag one.
- Add settings copy describing current platform defaults and drag interception.
- Rework README for public audience, including Bun build commands and debugging tips.
- Add fallback for missing drag icon, using a tiny embedded image on macOS.
- Remove original hand‑written main.js test script.

* docs(readme): rewrite and update installation, usage, and build instructions

- Clarify plugin purpose and usage
- Update build commands to use Bun
- Add platform notes and modifier key details
- Improve formatting and consistency

* refactor(main.js): add base64 icon fallback and update modifier key text

* feat(main.ts): add fallback drag icon for macOS and improve icon handling

* docs(changelog): add minAppVersion validation to release script abort condition

* refactor(release.mjs): validate minAppVersion and use it in versions.json
2026-04-25 03:03:49 -04:00

48 lines
1.1 KiB
JavaScript

import esbuild from "esbuild";
import process from "process";
import builtins from "builtin-modules";
const banner = `/*
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
if you want to view the source, please visit the github repository of this plugin
*/
`;
const prod = (process.argv[2] === "production");
const context = await esbuild.context({
banner: { js: banner },
entryPoints: ["main.ts"],
bundle: true,
external: [
"obsidian",
"electron",
"@electron/remote",
"@codemirror/autocomplete",
"@codemirror/collab",
"@codemirror/commands",
"@codemirror/language",
"@codemirror/lint",
"@codemirror/search",
"@codemirror/state",
"@codemirror/view",
"@lezer/common",
"@lezer/highlight",
"@lezer/lr",
...builtins
],
format: "cjs",
target: "es2018",
logLevel: "info",
sourcemap: prod ? false : "inline",
treeShaking: true,
outfile: "main.js",
minify: prod,
});
if (prod) {
await context.rebuild();
process.exit(0);
} else {
await context.watch();
}