MCPcopy Create free account
hub / github.com/nuxt/icon / _resolveServerBundle

Method _resolveServerBundle

src/context.ts:67–123  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

65 }
66
67 private async _resolveServerBundle(): Promise<ResolvedServerBundleOptions> {
68 let serverBundle = this.options.serverBundle
69 if (serverBundle === 'auto') {
70 const preset = this._nitroPreset || (typeof this.nuxt.options.nitro.preset === 'string'
71 ? this.nuxt.options.nitro.preset || provider
72 : provider)
73
74 serverBundle = 'local'
75
76 if (!this.nuxt.options.dev && KEYWORDS_EDGE_TARGETS.some(
77 word =>
78 (typeof preset === 'string' && preset.includes(word))
79 || process.env.NITRO_PRESET?.includes(word)
80 || process.env.SERVER_PRESET?.includes(word),
81 ))
82 serverBundle = 'remote'
83
84 logger.info(`Nuxt Icon server bundle mode is set to \`${serverBundle}\``)
85 }
86
87 const resolved = (!serverBundle || this.options.provider !== 'server')
88 ? { disabled: true }
89 : typeof serverBundle === 'string'
90 ? { remote: serverBundle === 'remote' }
91 : serverBundle
92
93 if (resolved.disabled) {
94 return {
95 disabled: true,
96 remote: false,
97 externalizeIconsJson: false,
98 collections: [],
99 }
100 }
101
102 if (!resolved.collections)
103 resolved.collections = resolved.remote
104 ? collectionNames
105 : await discoverInstalledCollections(getResolvePaths(this.nuxt))
106
107 const collections = await Promise.all(
108 (resolved.collections || [])
109 .map(c => resolveCollection(c, this.nuxt.options.rootDir)),
110 )
111
112 return {
113 disabled: false,
114 remote: resolved.remote === true
115 ? 'jsdelivr' // Default remote source
116 : resolved.remote || false,
117 externalizeIconsJson: !!resolved.externalizeIconsJson,
118 collections: [
119 ...collections,
120 ...await this.loadCustomCollection(),
121 ],
122 }
123 }
124

Callers 1

resolveServerBundleMethod · 0.95

Calls 4

loadCustomCollectionMethod · 0.95
getResolvePathsFunction · 0.90
resolveCollectionFunction · 0.90

Tested by

no test coverage detected