-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvite.config.ts
45 lines (42 loc) · 1.32 KB
/
vite.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import { defineConfig, loadEnv } from 'vite'
import { resolve, join } from 'path'
import scalaJS from '@scala-js/vite-plugin-scalajs'
import monacoEditorPluginModule from 'vite-plugin-monaco-editor'
const isObjectWithDefaultFunction = (module: unknown): module is { default: typeof monacoEditorPluginModule } => (
module != null &&
typeof module === 'object' &&
'default' in module &&
typeof module.default === 'function'
)
const monacoEditorPlugin = isObjectWithDefaultFunction(monacoEditorPluginModule)
? monacoEditorPluginModule.default
: monacoEditorPluginModule
// https://vitejs.dev/config/
export default defineConfig(({ command, mode }) => {
const env = loadEnv(mode, process.cwd(), '')
let basePath;
if(env["GITHUB_ACTIONS"] === "true") {
basePath = "/" + env["GITHUB_REPOSITORY"].split("/")[1]
} else {
basePath = "/"
}
const monacoWorkerPath = "monacoeditorwork"
return {
base: basePath,
plugins: [
scalaJS({
cwd: './scalajs'
}),
monacoEditorPlugin({
languageWorkers: ['editorWorkerService'],
publicPath: monacoWorkerPath,
customDistPath: (root: string, buildOutDir: string, base: string) => {
return join(root, buildOutDir, /* don't join base, */ monacoWorkerPath)
}
})
],
worker: {
format: 'iife'
}
}
})