diff options
Diffstat (limited to 'viewer/src/components/index.ts')
-rw-r--r-- | viewer/src/components/index.ts | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/viewer/src/components/index.ts b/viewer/src/components/index.ts new file mode 100644 index 0000000..1406b34 --- /dev/null +++ b/viewer/src/components/index.ts | |||
@@ -0,0 +1,22 @@ | |||
1 | import Vue from 'vue' | ||
2 | |||
3 | const requireComponent = require.context( | ||
4 | '@/components', | ||
5 | false, // Whether or not to look in subfolders | ||
6 | // The regular expression used to match base component filenames | ||
7 | /Ld[A-Z]\w+\.vue$/ | ||
8 | ) | ||
9 | |||
10 | requireComponent.keys().forEach(fileName => { | ||
11 | const componentConfig = requireComponent(fileName) | ||
12 | const componentName = fileName.split('/').pop()!.replace(/\.vue$/, ''); | ||
13 | |||
14 | // Register component globally | ||
15 | Vue.component( | ||
16 | componentName, | ||
17 | // Look for the component options on `.default`, which will | ||
18 | // exist if the component was exported with `export default`, | ||
19 | // otherwise fall back to module's root. | ||
20 | componentConfig.default || componentConfig | ||
21 | ) | ||
22 | }) \ No newline at end of file | ||