Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
dynamically add webpack entries
  • Loading branch information
kajan committed Feb 13, 2021
1 parent 72517eb commit 2290f56
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 0 deletions.
88 changes: 88 additions & 0 deletions AspNetCoreVueMpa.Web/ClientApp/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions AspNetCoreVueMpa.Web/ClientApp/package.json
Expand Up @@ -10,6 +10,7 @@
"author": "kajan",
"license": "ISC",
"devDependencies": {
"glob": "^7.1.6",
"vue-loader": "^15.9.6",
"vue-template-compiler": "^2.6.12",
"webpack": "^5.21.2",
Expand Down
17 changes: 17 additions & 0 deletions AspNetCoreVueMpa.Web/ClientApp/webpack.config.js
@@ -1,6 +1,23 @@
const VueLoaderPlugin = require('vue-loader/lib/plugin');
const glob = require('glob');

const entries = {};
const IGNORE_PATHS = ['unused'];

glob.sync('./views/**/main.js').forEach(path => {
const chunk = path.split('./views/')[1].split('/main.js')[0]
if (IGNORE_PATHS.every(path => !chunk.includes(path))) {
if (!chunk.includes('/')) {
entries[chunk] = path
} else {
const joinChunk = chunk.split('/').join('-')
entries[joinChunk] = path
}
}
});

module.exports = {
entry: entries,
module: {
rules: [
{
Expand Down

0 comments on commit 2290f56

Please sign in to comment.