From 599d6f71bb01591c5cff5c651796928be79d13fb Mon Sep 17 00:00:00 2001 From: Daniel Paz <42693974+danielpaz6@users.noreply.github.com> Date: Tue, 26 May 2020 01:22:28 +0300 Subject: [PATCH] Update Monaco Editor Example (#13369) Changed the URLs inside the Monaco Editor Example: https://github.com/zeit/next.js/tree/canary/examples/with-monaco-editor Converted the worker URL to start with the base URL. The reason is if you use the Monaco example anywhere but in the main `pages` folder, it won't work since it uses a relative URL instead. For example if we'll move the code to `pages/room/index.js` it won't work since it will try to search for the files inside `room/_next/_static/` instead of `_next/_static/`. The base URL I added fixes the problem. --- examples/with-monaco-editor/pages/index.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/with-monaco-editor/pages/index.js b/examples/with-monaco-editor/pages/index.js index c076b88519..1dd3f867e2 100644 --- a/examples/with-monaco-editor/pages/index.js +++ b/examples/with-monaco-editor/pages/index.js @@ -15,12 +15,12 @@ function IndexPage() { onChange={console.log} editorDidMount={() => { window.MonacoEnvironment.getWorkerUrl = (moduleId, label) => { - if (label === 'json') return '_next/static/json.worker.js' - if (label === 'css') return '_next/static/css.worker.js' - if (label === 'html') return '_next/static/html.worker.js' + if (label === 'json') return '/_next/static/json.worker.js' + if (label === 'css') return '/_next/static/css.worker.js' + if (label === 'html') return '/_next/static/html.worker.js' if (label === 'typescript' || label === 'javascript') - return '_next/static/ts.worker.js' - return '_next/static/editor.worker.js' + return '/_next/static/ts.worker.js' + return '/_next/static/editor.worker.js' } }} />