Angular Application Witch Ace Editor Error

In HyperKuber Web Project which is using angular 13 with ace editor for yaml/json display, an error occured in browser console, as follows

blob:https://console.apps.hyperkuber.io/70e118ca-2c6d-4de9-8248-2e8c29e51ede:1 Uncaught DOMException: Failed to execute 'importScripts' on 'WorkerGlobalScope': The script at 'https://console.apps.hyperkuber.io/worker-yaml.js' failed to load.
at blob:https://console.apps.hyperkuber.io/70e118ca-2c6d-4de9-8248-2e8c29e51ede:1:1

or

blob:https://console.apps.hyperkuber.io/70e118ca-2c6d-4de9-8248-2e8c29e51ede:1 Uncaught DOMException: Failed to execute 'importScripts' on 'WorkerGlobalScope': The script at 'https://console.apps.hyperkuber.io/worker-json.js' failed to load.
at blob:https://console.apps.hyperkuber.io/70e118ca-2c6d-4de9-8248-2e8c29e51ede:1:1

This is because these worker-*.js files were not placed in the right place when building in prod mode. add bellow configrations in angular.json file:

"assets": [
  "src/favicon.ico",
  "src/assets",
  { "glob": "worker-json.js", "input": "./node_modules/ace-builds/src-min/", "output": "/" },
  { "glob": "worker-yaml.js", "input": "./node_modules/ace-builds/src-min/", "output": "/" }
],
"scripts": [
   "./node_modules/ace-builds/src-min/ace.js",
   "./node_modules/ace-builds/src-min/worker-json.js",
   "./node_modules/ace-builds/src-min/worker-yaml.js",

],

Leave a Reply

Your email address will not be published. Required fields are marked *