Webpack Wildcard Support For Entry Points

August 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'),
  }
};

This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.