Skip to content

Commit fae6860

Browse files
committed
refactor(*): make build result CSP compliant
1 parent dcd6a59 commit fae6860

File tree

6 files changed

+18
-29
lines changed

6 files changed

+18
-29
lines changed

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"@material-design-icons/font": "^0.14.13",
4646
"axios": "^1.7.7",
4747
"dayjs": "^1.11.13",
48-
"monaco-editor": "0.52.0",
48+
"monaco-editor": "0.52.2",
4949
"pinia": "^3.0.1",
5050
"vue": "^3.5.12",
5151
"vue-router": "^4.4.5"
@@ -76,7 +76,6 @@
7676
"typescript": "^5.4.5",
7777
"vite": "^5.4.12",
7878
"vite-plugin-html": "^3.2.2",
79-
"vite-plugin-monaco-editor": "^1.1.0",
8079
"vue-tsc": "^2.1.4"
8180
},
8281
"browserslist": [

pnpm-lock.yaml

Lines changed: 2 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ import { registerGlobalComponents } from './registerGlobalComponents'
77
import './styles/index'
88
import { createPinia } from 'pinia'
99

10+
// This only sets up worker initializers. They will be lazy-loaded when needed.
11+
import '@/monaco-workers'
12+
1013
const i18n = createI18n<typeof english>('en-us', english, { isGlobal: true })
1114

1215
const app = createApp(App)

src/monaco-workers.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Injecting workers for monaco-editor
2+
3+
import EditorWorker from 'monaco-editor/esm/vs/editor/editor.worker?worker'
4+
5+
self.MonacoEnvironment = {
6+
getWorker() {
7+
return new EditorWorker()
8+
},
9+
}

tsconfig.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@
99
"tests/*": ["tests/*"],
1010
"config": ["src/config.ts"]
1111
},
12-
"moduleResolution": "node",
12+
"moduleResolution": "bundler",
1313
"resolveJsonModule": true,
1414
"allowJs": true,
1515
"noImplicitAny": false,
1616
"types": [
17-
"vite/client"
17+
"vite/client",
18+
"monaco-editor",
1819
]
1920
},
2021
"exclude": ["node_modules", "dist", "coverage", "tests"]

vite.config.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import path from 'path'
44
import autoprefixer from 'autoprefixer'
55
import { createHtmlPlugin } from 'vite-plugin-html'
66
import { visualizer } from 'rollup-plugin-visualizer'
7-
import monacoEditorPlugin from 'vite-plugin-monaco-editor'
87

98
const basePath = process.env.NODE_ENV !== 'production' || process.env.DISABLE_BASE_PATH === 'true' ? '/' : '/__km_base__/'
109

@@ -33,11 +32,6 @@ export default defineConfig({
3332
},
3433
},
3534
}),
36-
// See: https://github.com/vdesjs/vite-plugin-monaco-editor/issues/21
37-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
38-
((monacoEditorPlugin as any).default as typeof monacoEditorPlugin)({
39-
languageWorkers: ['editorWorkerService'],
40-
}),
4135
visualizer({
4236
filename: path.resolve(__dirname, 'bundle-analyzer/stats-treemap.html'),
4337
template: 'treemap', // sunburst|treemap|network

0 commit comments

Comments
 (0)