ngx-monaco-editor icon indicating copy to clipboard operation
ngx-monaco-editor copied to clipboard

Support base-href option

Open yowari opened this issue 6 years ago • 8 comments

ngx-monaco-editor does not take into account base-href option when building Angular app. For now, we have to configure baseUrl when importing the module. I think the component should be able to get the baseHref and use it as default path. Meaning, we should perhaps have by default ${baseHref}/assets instead of /assets. https://github.com/atularen/ngx-monaco-editor/blob/2ffca32ec03de436ef7ea2fa6d901eba7e638390/src/platform/editor/base-editor.ts#L40 To do so, we first have to inject the baseHref, which is not a simple thing to do 😛 (at least elegantly). My idea is to first extract a service from the BaseEditor class and then manage to inject the baseHref. What do you think? ps: For instance, I use a hacky way to do this behaviour without altering the code in my project https://github.com/yowari/code-challenger/blob/master/src/app/shared/shared.module.ts btw: first time trying to contribute to a GitHub project so please be kind :blush:

yowari avatar Jun 12 '18 12:06 yowari

I guess ./assets as default would be ok too 🤔

bboehm86 avatar Jul 26 '18 08:07 bboehm86

Well, if you don't provide --base-href option in ng build --prod, /assets will be used (default behaviour). This, for example, can help to set npm script to build Angular app for gh-pages and prod (exemple: for Docker) easily without changing code. The other ways is to set env variable for assets path or as i do in my project, retrieve the base-href path used. I already submitted a PR #64 . It not really a good solution but it works :confused:

yowari avatar Jul 26 '18 10:07 yowari

I'm facing that problem too. Any walkaround?

OK, after i wrote that i read @yowari comment once again and i'll try that way. Thanks =)

crevan236 avatar Aug 08 '18 09:08 crevan236

Seems that ./assets works too, like @bboehm86 suggested, though not sure why. I'm able to build for gh-pages by using the following import in AppModule:

MonacoEditorModule.forRoot({baseUrl: "./assets"})

gflegar avatar Aug 21 '18 03:08 gflegar

this doesn't work for me

pinktoadette avatar Dec 14 '18 17:12 pinktoadette

Seems that ./assets works too, like @bboehm86 suggested, though not sure why. I'm able to build for gh-pages by using the following import in AppModule:

MonacoEditorModule.forRoot({baseUrl: "./assets"})

This worked perfectly for me. It should be quoted in the Readme.md in my opinion

crisz avatar Jun 25 '19 09:06 crisz

It's doesn't work for me too

OleksandrGavryshko avatar Mar 25 '20 16:03 OleksandrGavryshko

it works fine for me, even with remote URL:

MonacoEditorModule.forRoot({
  baseUrl: 'http://localhost:53015/assets'
})

maitrungduc1410 avatar May 20 '23 04:05 maitrungduc1410