Webpack Wildcard Support For Entry Points

Aug 12, 2017
glob.sync("./src/*.js")

Using glob for wilcard support in webpack.config.js.

const path = require('path');const glob = require("glob");module.exports = {  entry: glob.sync("./src/*.js"),  output: {    filename: 'bundle.js',    path: path.resolve(__dirname, 'dist'),  }};

If your main module require/import other modules, all these modules shall be bundled automatically.

Example index.js require/import other modules.

var jquery = require('jquery');var util = require('./util.js');

webpack.config.js.

const path = require('path');module.exports = {  entry: path.resolve(__dirname, 'src/index.js'),  output: {    filename: 'bundle.js',    path: path.resolve(__dirname, 'dist'),  }};

❤️ Is this article helpful?

Buy me a coffee ☕ or support my work via PayPal to keep this space 🖖 and ad-free.

Do send some 💖 to @d_luaz or share this article.

✨ By Desmond Lua

A dream boy who enjoys making apps, travelling and making youtube videos. Follow me on @d_luaz

👶 Apps I built

Travelopy - discover travel places in Malaysia, Singapore, Taiwan, Japan.