Skip to content

Instantly share code, notes, and snippets.

@amritk
Created November 29, 2018 00:43
Show Gist options
  • Save amritk/880bf712badf4795fa3c106d9fff843b to your computer and use it in GitHub Desktop.
Save amritk/880bf712badf4795fa3c106d9fff843b to your computer and use it in GitHub Desktop.
Automatically import components
const fs = require('fs')
// Get component names
const components = []
fs.readdir('src/components', function (err, items) {
for (var i = 0; i < items.length; i++) {
components.push(items[i].slice(0, -4))
}
});
module.exports = {
baseUrl: '/admin/',
chainWebpack: config => {
config
.plugin('VuetifyLoaderPlugin')
.tap(args => {
return [{
match (originalTag, { kebabTag, camelTag }) {
if (components.indexOf(kebabTag) > -1) {
return [camelTag, `import ${camelTag} from '@/components/${kebabTag}.vue'`]
}
}
}]
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment