Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
ConnorHowell committed Jul 26, 2023
1 parent 7f06ae5 commit f39fdb9
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 10 deletions.
26 changes: 23 additions & 3 deletions bin/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,37 @@ const defaultOptions = {
}

compile({
...defaultOptions,
define: {
'process.env.NODE_ENV': isDev ? `'development'` : `'production'`,
},
bundle: true,
mainFields: ['module', 'main'],
platform: 'neutral',
sourcemap: isDev ? 'inline' : false,
sourcesContent: isDev,
treeShaking: true,
target: ['es2020'],
minify: !isDev,
format: 'iife',
entryPoints: {
"components/filament-monaco-editor": "./resources/js/index.js",
"editor.worker": "./node_modules/monaco-editor/esm/vs/editor/editor.worker.js",
"html.worker": "./node_modules/monaco-editor/esm/vs/language/html/html.worker.js",
"ts.worker": "./node_modules/monaco-editor/esm/vs/language/typescript/ts.worker.js",
"css.worker": "./node_modules/monaco-editor/esm/vs/language/css/css.worker.js",
"json.worker": "./node_modules/monaco-editor/esm/vs/language/json/json.worker.js",
},
outdir: "./resources/dist",
loader: {
".ttf": "file",
},
})

compile({
...defaultOptions,
entryPoints: {
"components/filament-monaco-editor": "./resources/js/index.js"
},
bundle: true,
format: 'iife',
outdir: "./resources/dist",
loader: {
".ttf": "file",
Expand Down
4 changes: 2 additions & 2 deletions resources/dist/components/filament-monaco-editor.js

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions resources/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@ window.MonacoEnvironment = {
globalAPI: true,
getWorkerUrl: (moduleId, label) => {
if (label === 'html' || label === 'handlebars') {
return '/js/connorhowell/filament-monaco-editor/html.worker.js';
return '/js/connorhowell/filament-monaco-editor/html-worker.js';
}

if (label === 'javascript' || label === 'typescript') {
return '/js/connorhowell/filament-monaco-editor/ts.worker.js';
return '/js/connorhowell/filament-monaco-editor/ts-worker.js';
}

if (label === 'scss' || label === 'less' || label === 'css') {
return '/js/connorhowell/filament-monaco-editor/css.worker.js';
return '/js/connorhowell/filament-monaco-editor/css-worker.js';
}

if (label === 'json') {
return '/js/connorhowell/filament-monaco-editor/json.worker.js';
return '/js/connorhowell/filament-monaco-editor/json-worker.js';
}

return '/js/connorhowell/filament-monaco-editor/editor.worker.js';
return '/js/connorhowell/filament-monaco-editor/editor-worker.js';
},
getWorker: (moduleId, label) => {
return new Worker(window.MonacoEnvironment.getWorkerUrl(moduleId, label));
Expand Down

0 comments on commit f39fdb9

Please sign in to comment.