Commit fe39b696 authored by Jérome Perrin's avatar Jérome Perrin

make "public path" configurable at run time

parent 4af71284
import "./public-path.js"
import * as monaco from 'monaco-editor'; import * as monaco from 'monaco-editor';
self.MonacoEnvironment = { self.MonacoEnvironment = {
getWorkerUrl: function (moduleId, label) { getWorkerUrl: function (moduleId, label) {
if (label === 'json') { if (label === 'json') {
return './json.worker.bundle.js'; return window.monacoEditorWebPackResourceBaseUrl + './json.worker.bundle.js';
} }
if (label === 'css') { if (label === 'css') {
return './css.worker.bundle.js'; return window.monacoEditorWebPackResourceBaseUrl + './css.worker.bundle.js';
} }
if (label === 'html') { if (label === 'html') {
return './html.worker.bundle.js'; return window.monacoEditorWebPackResourceBaseUrl + './html.worker.bundle.js';
} }
if (label === 'typescript' || label === 'javascript') { if (label === 'typescript' || label === 'javascript') {
return './ts.worker.bundle.js'; return window.monacoEditorWebPackResourceBaseUrl + './ts.worker.bundle.js';
} }
return './editor.worker.bundle.js'; return window.monacoEditorWebPackResourceBaseUrl + './editor.worker.bundle.js';
} }
} }
/* In the script on ERP5 we'll set this monacoEditorWebPackResourceBaseUrl to
* portal_url before loading monaco. This way the relative paths are resolved
* properly in ERP5 ( where a <base href=" is set ) and in the ZMI where no
* base is set. */
__webpack_public_path__ = window.monacoEditorWebPackResourceBaseUrl;
...@@ -14,7 +14,7 @@ module.exports = { ...@@ -14,7 +14,7 @@ module.exports = {
output: { output: {
globalObject: 'self', globalObject: 'self',
filename: '[name].bundle.js', filename: '[name].bundle.js',
path: path.resolve(__dirname, 'dist') path: path.resolve(__dirname, 'dist'),
}, },
module: { module: {
rules: [{ rules: [{
......
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