forked from Netcentric/fe-build
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerateEntries.js
More file actions
24 lines (19 loc) · 810 Bytes
/
generateEntries.js
File metadata and controls
24 lines (19 loc) · 810 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
const glob = require('fast-glob');
const path = require('path');
module.exports = function generateEntries(config, extension = 'js') {
const sourcePattern = `**/*.${config.general.sourceKey}.${extension}`;
const sourcesFiles = glob.sync(sourcePattern, { cwd: config.general.sourcesPath });
// if is multiple entries
if (config && config.general && config.general.multiple) {
const sources = {};
sourcesFiles.forEach((file) => {
const dir = path.dirname(file);
const fileName = path.basename(file);
const destFileName = fileName.replace(config.general.sourceKey, config.general.bundleKey);
const destFile = path.join(dir, destFileName);
sources[destFile] = path.join(config.general.sourcesPath, file);
});
return sources;
}
return sourcesFiles;
};