You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First, let me thank you for your plugin and the work you've put, it really helped us!
I've witnessed an error while using a basePath in my vite.config.js.
I have a feeling it's linked to #19 and maybe other issues.
I've reproduced the error in the smallest config possible in this repository: vite-monaco-basepath-error. It also contains the fix to the configuration to correct this behavior.
Quick summary
When specifying a base path in the config for vite, this plugin will use this basepath to calculate the dist directory for the workers. This produce a double nesting of the base path, rendering the workers impossible to load
Is there a workaround?
Yes, you just need to override the distPath by specifying customDistPath in the plugin config. You can see an exemple further down in the issue.
And when I do a yarn build, the monaco workers are put in dist/nested/monacoeditorwork, while the other assets are simply put in dist/assets without the nested part, meaning that trying to load the workers will fail:
And as you can see, if I try to directly go to /nested/nested/monacoeditorwork/json.worker.bundle.js, it will correctly show the file content:
My understanding is that the default distPath should not include the basepath, as the other assets in the vite pipeline are doing, but I'm not exactly sure.
At least, this workaround works for me and should for others!
The text was updated successfully, but these errors were encountered:
First, let me thank you for your plugin and the work you've put, it really helped us!
I've witnessed an error while using a
basePath
in myvite.config.js
.I have a feeling it's linked to #19 and maybe other issues.
I've reproduced the error in the smallest config possible in this repository: vite-monaco-basepath-error. It also contains the fix to the configuration to correct this behavior.
Quick summary
When specifying a base path in the config for
vite
, this plugin will use this basepath to calculate the dist directory for the workers. This produce a double nesting of the base path, rendering the workers impossible to loadIs there a workaround?
Yes, you just need to override the
distPath
by specifyingcustomDistPath
in the plugin config. You can see an exemple further down in the issue.Explanation with images
Here is the
vite.config.js
:And when I do a
yarn build
, the monaco workers are put indist/nested/monacoeditorwork
, while the other assets are simply put indist/assets
without thenested
part, meaning that trying to load the workers will fail:And as you can see, if I try to directly go to
/nested/nested/monacoeditorwork/json.worker.bundle.js
, it will correctly show the file content:I can fix this by customizing the dist path:
And it will work again.
What is the underlying problem?
My understanding is that the default
distPath
should not include the basepath, as the other assets in the vite pipeline are doing, but I'm not exactly sure.At least, this workaround works for me and should for others!
The text was updated successfully, but these errors were encountered: