Search code examples
javascriptwebpackglob

webpack.config adding multiple entries with glob.sync


I'm trying to add multiple entry points to my webpack.config file, but I'm having trouble getting it to work right. My idea was basically:

    var entryPoints = glob.sync('./Scripts/**.ts').reduce(function (obj, el) {
      obj[path.parse(el).name] = el;
      return obj
    }, {});
    entryPoints.push({
      a: path.join(__dirname, 'Content/a.scss'),
      b: path.join(__dirname, 'Content/b.scss'),}
);

    module.exports = {
      mode: 'development',
      devtool: 'source-map',
      entry: entryPoints,
...

but doing this i just get a 'TypeError: entryPoints.push is not a function'.

is there another better way to do what i want? And to answer perhaps another question, i don't want all the files in 'content/**.scss' to be included, only a small subset of files in there.


Solution

  • Try

    entryPoints.a = ...;
    entryPoints.b = ...;