Skip to content

Commit

Permalink
refactor entries generation to generate entries names independently f…
Browse files Browse the repository at this point in the history
…rom file extension

this makes it easier to extend this function to handle multiple file extensions by editing the path e.g. like this: "../src/application/*.{js,jsx,ts,tsx}"

targeting the typescript refactoring in this tutorial: https://www.accordbox.com/blog/how-to-add-typescript-to-the-django-project/
  • Loading branch information
Schulzjo committed Jun 15, 2023
1 parent 1c0ecc0 commit 4bd85d0
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@ const WebpackAssetsManifest = require("webpack-assets-manifest");

const getEntryObject = () => {
const entries = {};
glob.sync(Path.join(__dirname, "../src/application/*.js")).forEach((path) => {
const name = Path.basename(path, ".js");
entries[name] = path;
glob.sync(Path.join(__dirname, "../src/application/*.{js}")).forEach((path) => {

const name = Path.basename(path);
const extension = Path.extname(path);
const entryName = name.replace(extension, '');

entries[entryName] = path;
});
return entries;
};
Expand Down

0 comments on commit 4bd85d0

Please sign in to comment.