Skip to content

Commit

Permalink
fix: vite SSR build fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
favna committed Jan 27, 2023
1 parent 5969ca7 commit 3ae8299
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 14 deletions.
24 changes: 14 additions & 10 deletions docs/.vuepress/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,18 @@ export default defineClientConfig({
Layout
},
enhance({ router }) {
self.MonacoEnvironment = {
getWorker(_, label) {
switch (label) {
case 'json':
return new jsonWorker()
case 'typescript':
case 'javascript':
return new tsWorker()
default:
return editorWorker()
if (!__VUEPRESS_SSR__) {
self.MonacoEnvironment = {
getWorker(_, label) {
switch (label) {
case 'json':
return new jsonWorker()
case 'typescript':
case 'javascript':
return new tsWorker()
default:
return editorWorker()
}
}
}
}
Expand All @@ -46,6 +48,8 @@ export default defineClientConfig({
})

declare global {
const __VUEPRESS_SSR__: boolean

interface Window {
MonacoEnvironment?: import('monaco-editor').Environment | undefined
}
Expand Down
5 changes: 3 additions & 2 deletions docs/.vuepress/components/Demo/MonacoEditor.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<script setup lang="ts">
import loader from '@monaco-editor/loader'
import { isFunction } from '@sapphire/utilities'
import * as Monaco from 'monaco-editor'
import { computed, onMounted, ref, watch } from 'vue'
import loader from '@monaco-editor/loader';
interface Emits {
(event: 'update:modelValue', value: string): void
Expand All @@ -17,7 +18,7 @@ const props = defineProps<{
readonly?: boolean
}>()
const loadedMonaco = await loader.init();
const loadedMonaco = isFunction(loader.init) ? await loader.init() : undefined
const emit = defineEmits<Emits>()
const isLoading = ref(true)
Expand Down
6 changes: 4 additions & 2 deletions docs/.vuepress/components/TwitterFollow/TwitterFollow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@

<script setup lang="ts">
import { ref } from 'vue'
import TwitterBird from './TwitterBird.vue'
const url = new URL('https://twitter.com/intent/follow')
url.searchParams.append('original_referer', window.location.href)
url.searchParams.append(
'original_referer',
__VUEPRESS_SSR__ ? 'https://fusejs.io' : window.location.href
)
url.searchParams.append(
'ref_src',
encodeURIComponent('twsrc^tfw|twcamp^buttonembed|twterm^follow|twgr^kirorisk')
Expand Down

0 comments on commit 3ae8299

Please sign in to comment.