Skip to content

Commit 2290f56

Browse files
author
kajan
committed
dynamically add webpack entries
1 parent 72517eb commit 2290f56

File tree

3 files changed

+106
-0
lines changed

3 files changed

+106
-0
lines changed

AspNetCoreVueMpa.Web/ClientApp/package-lock.json

+88
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

AspNetCoreVueMpa.Web/ClientApp/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"author": "kajan",
1111
"license": "ISC",
1212
"devDependencies": {
13+
"glob": "^7.1.6",
1314
"vue-loader": "^15.9.6",
1415
"vue-template-compiler": "^2.6.12",
1516
"webpack": "^5.21.2",

AspNetCoreVueMpa.Web/ClientApp/webpack.config.js

+17
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,23 @@
11
const VueLoaderPlugin = require('vue-loader/lib/plugin');
2+
const glob = require('glob');
3+
4+
const entries = {};
5+
const IGNORE_PATHS = ['unused'];
6+
7+
glob.sync('./views/**/main.js').forEach(path => {
8+
const chunk = path.split('./views/')[1].split('/main.js')[0]
9+
if (IGNORE_PATHS.every(path => !chunk.includes(path))) {
10+
if (!chunk.includes('/')) {
11+
entries[chunk] = path
12+
} else {
13+
const joinChunk = chunk.split('/').join('-')
14+
entries[joinChunk] = path
15+
}
16+
}
17+
});
218

319
module.exports = {
20+
entry: entries,
421
module: {
522
rules: [
623
{

0 commit comments

Comments
 (0)