0

I'm building an Obsidian plugin, and it uses esbuild to bundle ts file to js file. The ts file is located at D:\foo1\foo2\..., and I want the js file to be at D:\bar1\bar2\.... The reason for this is because I want the source folder is in a different folder than the plugin folder, so that when syncing it to mobile I don't have to exclude the source files.

I was suggested to edit the esbuild.config.mjs file, and I find in the documentation that beside the outfile config there are also outdir, outbase. However, these are the results when I'm using them:

outdir

outdir: 'D:\Quả Cầu\B Nội dung\Knowledge graphs\Cây vấn đề\.obsidian\plugins\dotmaker'

error: Failed to create output directory: mkdir D:\GitHub\Obsidian\dotmaker\D:Quả CầuB Nội dungKnowledge graphsCây vấn đề.obsidianpluginsdotmaker: The directory name is invalid.

outbase

outbase: 'D:\Quả Cầu\B Nội dung\Knowledge graphs\Cây vấn đề\.obsidian\plugins\dotmaker',

It prints the js content in the terminal, but the real file isn't changed.

It seems that I can only create the js file inside the source folder. Is that possible?

Ooker
  • 1,969
  • 4
  • 28
  • 58
  • 1
    Because the examples probably used unix style path separators ( ie forward slashes `/`) and not windows style path separators (ie backslashes `\ ` ). A backslash in a javascript (and most other languages) string has a [special meaning](https://stackoverflow.com/questions/3903488/javascript-backslash-in-variables-is-causing-an-error) so if you want your string to literally contain a backslash you have to escape it. – derpirscher Feb 08 '22 at 10:15

1 Answers1

1

You didn't correctly format the content of the outdir setting. When using backslashes \ as path separator on windows, you have to escape them. Ie use

outdir: 'D:\\Quả Cầu\\B Nội dung\\Knowledge graphs\\Cây vấn đề\\.obsidian\\plugins\\dotmaker'
derpirscher
  • 14,418
  • 3
  • 18
  • 35