Skip to content Skip to sidebar Skip to footer

Webpack Multiple Entries In A Directory

context: path.join(__dirname, 'resources/assets/bundle/js'), entry: [ 'webpack/hot/dev-server', 'webpack-hot-middleware/client', './*.js' ] Is above code even vali

Solution 1:

Why do you use the entire folder?

if you want entire folder , you can use glob npm module

As explained : https://github.com/webpack/webpack/issues/370

var glob = require("glob");
// ...entry: glob.sync("./src/scripts/*.js")

but webpack is not recommended entire folder, the entry value should resolve to a specific file, or a list of specific files.

Solution 2:

You can easily do this by your own, as the webpack.config.js is just a node.js module and allows to execute any code. Wildcards in entry points

Solution 3:

Webpack uses entry point to resolve the reference to generate the bundle. you can define multiple entry point based on the number of bundle needed. you should not be adding entire folder as entry point, it means you want bundle of each file inside the folder, which webpack does not recommend.

https://webpack.github.io/docs/multiple-entry-points.html

Post a Comment for "Webpack Multiple Entries In A Directory"