Skip to content

Commit

Permalink
feat: export ScriptDescriptor type
Browse files Browse the repository at this point in the history
  • Loading branch information
hemengke1997 committed Oct 30, 2023
1 parent 062325a commit ef1dd60
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/node/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,5 +190,5 @@ export default function publicTypescript(options: VPPTPluginOptions = {}) {
}

export { getManifest } from './manifest-cache'
export { injectScripts, injectScriptsToHtml } from './plugins/inject-script'
export { type ScriptDescriptor, injectScripts, injectScriptsToHtml } from './plugins/inject-script'
export { publicTypescript }
7 changes: 4 additions & 3 deletions src/node/plugins/inject-script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ import { type HtmlTagDescriptor, type PluginOption } from 'vite'
import { VPPT_DATA_ATTR, injectTagsToHtml } from '../helper/html'
import { getManifest } from '../manifest-cache'

export type Scripts = (manifest: Record<string, string>) => Omit<HtmlTagDescriptor, 'tag'>[]
export type ScriptDescriptor = Omit<HtmlTagDescriptor, 'tag'>[]
export type Scripts = (manifest: Record<string, string>) => ScriptDescriptor

function generateScriptTags(scripts: Scripts) {
const _scripts = scripts(getManifest())
const tags: HtmlTagDescriptor[] = _scripts?.map((s) => ({
const _scripts = scripts(getManifest()) || []
const tags: HtmlTagDescriptor[] = _scripts.map((s) => ({
...s,
attrs: {
crossorigin: true,
Expand Down

0 comments on commit ef1dd60

Please sign in to comment.