Skip to content

Commit

Permalink
Fix: Monaco 404 errors (#3222)
Browse files Browse the repository at this point in the history
  • Loading branch information
ElinorW authored Jun 19, 2024
1 parent 552a2cb commit 072f4e6
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
4 changes: 4 additions & 0 deletions config/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,10 @@ module.exports = function (webpackEnv) {
'sass-loader'
)
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader']
},
{
test: /\.ttf$/,
type: 'asset/resource'
Expand Down
37 changes: 37 additions & 0 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,43 @@ function loadResources() {
}
loadResources();

/**
* Set's up Monaco Editor's Workers.
*/
enum Workers {
Json = 'json',
Editor = 'editor',
Typescript='ts',
Css='css',
Html='html'
}

window.MonacoEnvironment = {
getWorkerUrl(moduleId: any, label: string) {
switch (label) {
case 'json':
return getWorkerFor(Workers.Json);
case 'css':
return getWorkerFor(Workers.Css);
case 'html':
return getWorkerFor(Workers.Html);
case 'typescript':
return getWorkerFor(Workers.Typescript);
default:
return getWorkerFor(Workers.Editor);
}
}
};

function getWorkerFor(worker: string): string {
// tslint:disable-next-line:max-line-length
const WORKER_PATH =
'https://graphstagingblobstorage.blob.core.windows.net/staging/vendor/bower_components/explorer-v2/build';

return `data:text/javascript;charset=utf-8,${encodeURIComponent(`
importScripts('${WORKER_PATH}/${worker}.worker.js');`)}`;
}

variantService.initialize();
const telemetryProvider: ITelemetry = telemetry;
telemetryProvider.initialize();
Expand Down
3 changes: 3 additions & 0 deletions src/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { Environment } from 'monaco-editor/esm/vs/editor/editor.api';

export {};
declare global {
interface Window {
ClientId: string | undefined
MonacoEnvironment: Environment;
}
}

Expand Down

0 comments on commit 072f4e6

Please sign in to comment.