Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support base-href option #63

Open
yowari opened this issue Jun 12, 2018 · 8 comments
Open

Support base-href option #63

yowari opened this issue Jun 12, 2018 · 8 comments

Comments

@yowari
Copy link

yowari commented Jun 12, 2018

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.

const baseUrl = this.config.baseUrl || '/assets';

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 😊

@bboehm86
Copy link

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

@yowari
Copy link
Author

yowari commented Jul 26, 2018

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 😕

@crevan236
Copy link

crevan236 commented Aug 8, 2018

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 =)

@gflegar
Copy link

gflegar commented Aug 21, 2018

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"})

@pinktoadette
Copy link

this doesn't work for me

@crisz
Copy link

crisz commented Jun 25, 2019

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

@OleksandrGavryshko
Copy link

It's doesn't work for me too

@maitrungduc1410
Copy link

it works fine for me, even with remote URL:

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants