1 |
|
2 | const { sync } = require('glob');
|
3 | const { basename, resolve } = require('path');
|
4 | const extname = require('path-complete-extname');
|
5 | const config = require('@rails/webpacker/package/config');
|
6 |
|
7 | const { extensions, source_path, source_entry_path } = config;
|
8 |
|
9 | const extensionGlob = `*{${extensions.join(',')}}*`;
|
10 | const packPaths = sync(resolve(source_path, source_entry_path, extensionGlob));
|
11 |
|
12 | module.exports = packPaths.reduce((map, entry, i) => {
|
13 | const bname = basename(entry, extname(entry));
|
14 | const localMap = map;
|
15 | const path = ['./' + source_entry_path + '/' + basename(entry)];
|
16 | if (i === 0) {
|
17 | path.push('@morsedigital/morse-marker');
|
18 | }
|
19 | localMap[bname] = path;
|
20 | return localMap;
|
21 | }, {});
|