Skip to content

Instantly share code, notes, and snippets.

@kevcodez
Created March 17, 2021 07:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kevcodez/512ab3b368b5d690d925d30e00d7fec6 to your computer and use it in GitHub Desktop.
Save kevcodez/512ab3b368b5d690d925d30e00d7fec6 to your computer and use it in GitHub Desktop.
register custom components in nuxt
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