Skip to content

[FR] Support multiple output paths and repository-stored constants. #36

@hollowhemlock

Description

@hollowhemlock

Description

Add support for:

  1. Global constants that can be stored in the repository alongside .env variables
  2. Multiple output paths by building once and copying to multiple destinations

Reference implementation: https://github.com/mnaoumov/obsidian-dev-utils/blob/main/docs/cli-commands.md#build-development-version

Details

Currently, the build process requires custom scripting to copy built files to multiple locations. This feature would streamline the development workflow by:

  • Allowing constants to be defined in a configuration file that's committed to the repository
  • Supporting multiple output paths natively, eliminating the need for manual copy operations
  • Support generating an obsidian vault folder using the https://github.com/mnaoumov/generator-obsidian-plugin

Desired Behavior

  • Accept global constants in addition to .env variables that can be version-controlled with the repository
  • Support configuring multiple output paths in the build configuration
  • Build the plugin once and automatically copy to all specified destinations

Current Behavior

Currently using a custom hook to achieve this functionality:

scripts\dev.ts

import {
  BuildMode,
  buildObsidianPlugin,
} from "obsidian-dev-utils/ScriptUtils/esbuild/ObsidianPluginBuilder";
import fs from "fs/promises";
import path from "path";

export async function invoke(): Promise<CliTaskResult> {
  try {
    console.log("Building plugin in development mode...");

    const result = await buildObsidianPlugin({ mode: BuildMode.Development });

    // Verify build output exists
    const distDir = path.join(process.cwd(), "dist/dev");
    try {
      await fs.access(distDir);
    } catch {
      throw new Error(`Build output not found at ${distDir}`);
    }

    // Copy to test vault
    const testVaultPluginDir = path.join(
      process.cwd(),
      "test-vault/.obsidian/plugins/my-plugin"
    );

    await fs.mkdir(testVaultPluginDir, { recursive: true });
    await fs.cp(distDir, testVaultPluginDir, { recursive: true, force: true });
    console.log("Copied to test vault:", testVaultPluginDir);
    return result;
  } catch (error) {
    console.error("Build failed:", error);
    throw error;
  }
}

Attachments

Not applicable for this feature request.

Confirmations

  • I attached a video showing the current behavior, or it is not necessary
  • I have tested the absence of the requested feature with the latest version of the utils
  • I have checked GitHub for existing Feature Requests

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestquestionFurther information is requested

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions