Skip to content

Instantly share code, notes, and snippets.

@anfibiacreativa
Last active July 12, 2019 16:06
Show Gist options
  • Save anfibiacreativa/133f9ba9942ba1a38f9b28fffc7a3bf8 to your computer and use it in GitHub Desktop.
Save anfibiacreativa/133f9ba9942ba1a38f9b28fffc7a3bf8 to your computer and use it in GitHub Desktop.
const glob = require('fast-glob');
const path = require('path');
function collectEntries(config, extension) {
// we have called all our js and scss files like this `component-name.entry.js` and `component-name.entry.scss`
const pattern = `**/*.entry.${extension}`;
// if you take a look at project structure we defined
// and the project.paths.conig.js file above, you will see the path to iterate in this case
// is the `tenants/tenantN/components/package/src/frontend/components`
// since when globbing cwd will be the directory where this file is at
// you need to pass this path as options
const options = { cwd: `tenants/tenantN/components/package/src/frontend/components` };
const tree = glob.sync(pattern, options);
let sources = {};
tree.forEach((file) => {
// operate here
});
return sources;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment