Nuxt icon font generator
Note: This is Nuxt 3 compatible module only.
<template>
<p>I'm a text with icon!</p>
</template>
<style scoped lang="scss">
p {
&:before {
content: var(--icon-font-house);
font-family: "icon-font";
}
}
</style>
@coremyslo/nuxt-icon-font dependency to your projectnpx nuxi@latest module add icon-font
my-module to the modules section of nuxt.config.tsexport default defineNuxtConfig({
modules: [
"@coremyslo/nuxt-icon-font"
]
})
nuxt.config.ts. Below is the default configuration.export default defineNuxtConfig({
// ...
iconFont: {
// Font name to be used in "font-family" and custom properties generated prefix "--icon-font-svgiconfilename"
name: "icon-font",
// folder with icons to watch
sourceDirPath: "assets/icon-font",
// target folder for generated fonts in "public" folder
targetDirPath: "icon-font",
// font formats to generate, fallback to ["woff2"] in case browserslist is not used, example for manual configuration: ["svg", "ttf", "woff", "woff2", "eot"] in any order
formats: getFontFormatsList(browserslist()),
// Generates font in memory as "woff" and injects it as base64 to reduce page jump effect, ignores "formats" option
base64: true,
// unicode symbol for first icon in iconfont (makes sense to change only if you're not going to use custom properties)
unicode: "0xE900",
// generated custom properties (variables) format. Other options are: "snake", "pascal", "camel", "header", "constant"
case: "kebab"
}
})