aboutsummaryrefslogtreecommitdiff
path: root/viewer/src/components/index.ts
blob: 4586f6298098512c0c17be8ffed7200ed1023933 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import Vue from 'vue'

const requireComponent = require.context(
    '@/components',
    false, // Whether or not to look in subfolders
    // The regular expression used to match base component filenames
    /Ld[A-Z]\w+\.vue$/
)

requireComponent.keys().forEach(fileName => {
    const componentConfig = requireComponent(fileName)
    const componentName = fileName.split('/').pop()!.replace(/\.vue$/, '');

    // Register component globally
    Vue.component(
        componentName,
        // Look for the component options on `.default`, which will
        // exist if the component was exported with `export default`,
        // otherwise fall back to module's root.
        componentConfig.default ?? componentConfig
    )
})