Skip to content

Commit

Permalink
refactor: OFFICE_JS_LOADER_SNIPPET
Browse files Browse the repository at this point in the history
  • Loading branch information
DaPotatoMan committed Apr 3, 2024
1 parent 54fd347 commit 0f2f003
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/runtime/loader.server.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type { OfficeAddinVirtualContext } from '../vite/types'
import { OFFICE_JS_LOADER_SNIPPET } from '../vite/utils'

// @ts-expect-error virtual import
import context from '#office-addin-content'

export default defineNitroPlugin(async (nitroApp) => {
const { manifests, options } = context as OfficeAddinVirtualContext
const OFFICE_JS_URL = 'https://appsforoffice.microsoft.com/lib/1.1/hosted/office.js'

if (!options || !options.manifests.length)
return
Expand Down Expand Up @@ -33,6 +33,6 @@ export default defineNitroPlugin(async (nitroApp) => {
)

if (matches)
html.head.push(`<script src="${OFFICE_JS_URL}" async defer></script>`)
html.head.push(OFFICE_JS_LOADER_SNIPPET)
})
})
3 changes: 3 additions & 0 deletions src/vite/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import { resolve } from 'node:path'
import { loadEnv, normalizePath } from 'vite'
import type { ManifestEntry, ManifestEntryContent } from './types'

export const OFFICE_JS_URL = 'https://appsforoffice.microsoft.com/lib/1.1/hosted/office.js'
export const OFFICE_JS_LOADER_SNIPPET = `<script src="${OFFICE_JS_URL}" async defer></script>`

export function getPath(paths: string[]) {
return normalizePath(resolve(...paths))
}
Expand Down

0 comments on commit 0f2f003

Please sign in to comment.