Icons
@weconstudio/nuxt registers @nuxt/icon with the client bundle enabled. Icons used by the app are embedded in the client bundle, so no request goes to the Iconify API at runtime and icons keep working offline.
Default configuration
The module sets these icon defaults; anything you put under icon in nuxt.config.ts is merged on top:
ts
icon: {
clientBundle: {
scan: {
globInclude: ['**/*.{vue,js,ts}'],
globExclude: ['node_modules', 'dist', 'build', 'coverage', 'test', 'tests', '.*'],
},
// with vuetify-nuxt-module: the icons used by Vuetify and by the module components
icons: [/* 'mdi:magnify', 'mdi:close', ... */],
},
},Add icons that the scan cannot find (e.g. names built at runtime) to clientBundle.icons:
ts
icon: {
clientBundle: {
icons: ['mdi:account-circle', 'mdi:file-pdf-box'],
},
},Required dependencies
Install the Iconify JSON package of every icon set you use, at least MDI:
sh
pnpm add -D @iconify-json/mdish
pnpm add -D @iconify-json/material-symbols # for each extra setWARNING
Icons of a set whose @iconify-json/* package is not installed are not bundled.
With Vuetify
When vuetify-nuxt-module is installed, the module also:
- registers a
nuxtIconVuetify icon set backed by@nuxt/iconand makes it the default set, so<v-icon>mdi-close</v-icon>andicon="mdi-close"render through@nuxt/icon; - adds its own aliases, usable as
$name($search,$save,$trash,$refresh,$filter,$columns,$booleanOn, ...); - adds the Vuetify aliases (
$close,$expand,$prev, ...) and the module aliases toclientBundle.icons, convertingmdi-nametomdi:name, so the icons used inside Vuetify components are bundled even if they never appear in your source.
Without vuetify-nuxt-module none of this applies: use <Icon name="mdi:close" /> directly.
How it works
- The scan reads all
.vue,.jsand.tsfiles and collects the icon names it finds. - With Vuetify, the alias icons are added to the list.
- The SVGs of the collected icons are taken from the installed
@iconify-json/*packages and embedded in the client bundle.