I'm currently working on setting up automatic global registration. I'm encountering difficulty in finding a way to exclude a specific sub directory. Can someone provide an example of a regex pattern for excluding a particular directory? Unfortunately, I don't have any attempts to show as I am unsure where to start. I tried searching online and found some examples, but none of them seem to match the requirement of excluding only a directory.
Below is the code snippet that I am using to get the components:
const registerComponents = () => {
const pascalCase = (name: string) => {
return _.chain(name).camelCase().upperFirst().value()
}
const context = require.context('@/components', true, /\w+\.(vue)$/)
_.forEach(context.keys(), fileName => {
const componentConfig = context(fileName)
const name = (fileName.split('/').pop() || '').replace(/\.\w+$/, '')
const componentName = pascalCase(name)
Vue.component(componentName, componentConfig.default || componentConfig)
})
}
This is how the structure looks like. I want to exclude the folder /_exclude/
components/_exclude/file.vue
components/_exclude/file2.vue
components/_exclude/svg/globe.vue
components/some-file.vue
components/svg/cart.vue