Created
November 29, 2018 00:43
-
-
Save amritk/880bf712badf4795fa3c106d9fff843b to your computer and use it in GitHub Desktop.
Automatically import components
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
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