Unverified Commit 599d6f71 authored by Daniel Paz's avatar Daniel Paz Committed by GitHub

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.
parent 2e1a322d
...@@ -15,12 +15,12 @@ function IndexPage() { ...@@ -15,12 +15,12 @@ function IndexPage() {
onChange={console.log} onChange={console.log}
editorDidMount={() => { editorDidMount={() => {
window.MonacoEnvironment.getWorkerUrl = (moduleId, label) => { window.MonacoEnvironment.getWorkerUrl = (moduleId, label) => {
if (label === 'json') return '_next/static/json.worker.js' if (label === 'json') return '/_next/static/json.worker.js'
if (label === 'css') return '_next/static/css.worker.js' if (label === 'css') return '/_next/static/css.worker.js'
if (label === 'html') return '_next/static/html.worker.js' if (label === 'html') return '/_next/static/html.worker.js'
if (label === 'typescript' || label === 'javascript') if (label === 'typescript' || label === 'javascript')
return '_next/static/ts.worker.js' return '/_next/static/ts.worker.js'
return '_next/static/editor.worker.js' return '/_next/static/editor.worker.js'
} }
}} }}
/> />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment