fix monaco editor config to ensure service workers are not loaded from cross-domain origins

This commit is contained in:
Mike Greiling 2018-02-08 15:36:11 -06:00
parent 4342e3915c
commit e5c8a47cbb
No known key found for this signature in database
GPG key ID: 0303DF507FA67596

View file

@ -6,6 +6,11 @@ monacoContext.require.config({
},
});
// ignore CDN config and use local assets path for service worker which cannot be cross-domain
const relativeRootPath = (gon && gon.relative_url_root) || '';
const monacoPath = `${relativeRootPath}/assets/webpack/monaco-editor/vs`;
window.MonacoEnvironment = { getWorkerUrl: () => `${monacoPath}/base/worker/workerMain.js` };
// eslint-disable-next-line no-underscore-dangle
window.__monaco_context__ = monacoContext;
export default monacoContext.require;