Created
March 17, 2021 07:35
-
-
Save kevcodez/512ab3b368b5d690d925d30e00d7fec6 to your computer and use it in GitHub Desktop.
register custom components in nuxt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { join } from "path"; | |
export default function () { | |
const { nuxt } = this | |
// Make sure components is enabled | |
if (!nuxt.options.components) { | |
throw new Error('please set `components: true` inside `nuxt.config` and ensure using `nuxt >= 2.13.0`') | |
} | |
this.nuxt.hook("components:dirs", (dirs) => { | |
// Add ./components dir to the list | |
dirs.push({ | |
path: join(__dirname, "../components"), | |
prefix: "micro", | |
}); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment