Skip to content

Instantly share code, notes, and snippets.

@adrianjost
Last active January 31, 2020 11:17
Show Gist options
  • Save adrianjost/46d17993266d9a6d6b058b4b953f34c9 to your computer and use it in GitHub Desktop.
Save adrianjost/46d17993266d9a6d6b058b4b953f34c9 to your computer and use it in GitHub Desktop.
NuxtJS Theming - Component Alias - https://medium.com/p/2567ef5b5b6a
const path = require("path");
const aliases = {
// required to not break nuxt
"@": "src",
"@@": ".",
// custom aliases
"@components": "src/components",
}
// export resolved aliases
for (const alias in aliases) {
module.exports[alias] = path.resolve(__dirname, aliases[alias])
}
// nuxt.config.js
export default {
build: {
extend(config, ctx) {
Object.assign(config.resolve.alias, require("./aliases.config"));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment