A
A
amiznikov2018-03-16 09:50:43
JavaScript
amiznikov, 2018-03-16 09:50:43

Adding multiple files, entry multiple webpack?

webpackConfig.entry = {
"main": path.resolve(__dirname, 'src/main.js'),
"skin-*": path.resolve(__dirname, 'src/skins/skin-*/main.js') ,
}
there are three folders:
src/skins/skin-1/main.js
src/skins/skin-2/main.js
src/skins/skin-3/main.js Webpack
needs to create the required entryChunkName for each folder and correspondingly, the output was the same. Thank you!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
amiznikov, 2018-03-16
@amiznikov

Found the answer:
function toObject(paths) {
var ret = {};
paths.forEach(function(path) {
// you can define entry names mapped to [name] here
ret[path.split('/').slice(-2)[0]] = __dirname + "/" + path ;
});
return ret;
}
let entry = Object.assign({}, {"gcore": path.resolve(main, 'src/main.js')}, toObject(glob.sync('src/skin/skin-*/*.js ')))
webpackConfig.entry = entry;
Thanks to all!:)

Z
zim32, 2018-03-16
@zim32

So in the output you can specify placeholders

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question