Skip to content

Commit 4bd85d0

Browse files
committed
refactor entries generation to generate entries names independently from 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/
1 parent 1c0ecc0 commit 4bd85d0

File tree

1 file changed

+7
-3
lines changed
  • webpack_boilerplate/frontend_template/{{cookiecutter.project_slug}}/webpack

1 file changed

+7
-3
lines changed

webpack_boilerplate/frontend_template/{{cookiecutter.project_slug}}/webpack/webpack.common.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,13 @@ const WebpackAssetsManifest = require("webpack-assets-manifest");
66

77
const getEntryObject = () => {
88
const entries = {};
9-
glob.sync(Path.join(__dirname, "../src/application/*.js")).forEach((path) => {
10-
const name = Path.basename(path, ".js");
11-
entries[name] = path;
9+
glob.sync(Path.join(__dirname, "../src/application/*.{js}")).forEach((path) => {
10+
11+
const name = Path.basename(path);
12+
const extension = Path.extname(path);
13+
const entryName = name.replace(extension, '');
14+
15+
entries[entryName] = path;
1216
});
1317
return entries;
1418
};

0 commit comments

Comments
 (0)