webpack: Simplify module.entries

Drop the "qualify" loop and add the src/ subdirectory to the path
directly. This is more explicit, thus easier to understand, and simpler.

Also move it into the `modules` declaration directly, so that (1) it's
easier to see what it actually means, and (2) info.files is for a
completely different purpose.
This commit is contained in:
Martin Pitt 2020-11-22 12:28:24 +01:00 committed by Katerina Koukiou
parent 8aad356edb
commit 230c338a5a

View file

@ -15,11 +15,6 @@ const nodedir = path.resolve((process.env.SRCDIR || __dirname), "node_modules");
var production = process.env.NODE_ENV === 'production'; var production = process.env.NODE_ENV === 'production';
var info = { var info = {
entries: {
"index": [
"./index.js"
]
},
files: [ files: [
"index.html", "index.html",
"manifest.json", "manifest.json",
@ -43,21 +38,6 @@ function vpath(/* ... */) {
return expanded; return expanded;
} }
/* Qualify all the paths in entries */
Object.keys(info.entries).forEach(function(key) {
if (section && key.indexOf(section) !== 0) {
delete info.entries[key];
return;
}
info.entries[key] = info.entries[key].map(function(value) {
if (value.indexOf("/") === -1)
return value;
else
return vpath(value);
});
});
/* Qualify all the paths in files listed */ /* Qualify all the paths in files listed */
var files = []; var files = [];
info.files.forEach(function(value) { info.files.forEach(function(value) {
@ -110,7 +90,9 @@ module.exports = {
watchOptions: { watchOptions: {
ignored: /node_modules/, ignored: /node_modules/,
}, },
entry: info.entries, entry: {
index: "./src/index.js",
},
// cockpit.js gets included via <script>, everything else should be bundled // cockpit.js gets included via <script>, everything else should be bundled
externals: { "cockpit": "cockpit" }, externals: { "cockpit": "cockpit" },
devtool: "source-map", devtool: "source-map",