@lipemat/js-boilerplate
Version:
Dependencies and scripts for a no config JavaScript app
28 lines • 929 B
JavaScript
import { getConfig } from './config.js';
import { getPackageConfig } from '@lipemat/js-boilerplate-shared/helpers/package-config.js';
import { existsSync } from 'fs';
import { resolve } from 'path';
const entries = await getConfig('entries.config.js');
/**
* Entry points to be loaded by Webpack.
*
* Checks for sources in the order they are defined and creates a
* single entry per key if a source file exists.
*
* @see entries.config.js
*/
export function getEntries() {
const matches = {};
Object.keys(entries).forEach(name => {
entries[name].some(possibleFile => {
const filePath = getPackageConfig().workingDirectory + '/src/' + possibleFile;
if (existsSync(resolve(filePath))) {
matches[name] = resolve(filePath);
return true;
}
return false;
});
});
return matches;
}
//# sourceMappingURL=entries.js.map