aboutsummaryrefslogtreecommitdiff
path: root/viewer/src/components/index.ts
blob: 1406b3474f62d02ff23582b5f0becf748551f242 (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
    )
})