const path = require('path');
const { readdirSync } = require('fs');

const allWidgets = readdirSync(path.resolve(__dirname, 'src/components'));

module.exports = {
  mode: 'production',
  entry: {
    VeritoneApp: path.resolve(__dirname, 'src/shared/VeritoneApp.js'),
    // one entry for each widget
    ...allWidgets.reduce(
      (result, widgetName) => ({
        ...result,
        [widgetName]: path.resolve(
          __dirname,
          `src/components/${widgetName}/index.js`
        )
      }),
      {}
    )
  },
  output: {
    library: '[name]',
    libraryTarget: 'umd',
    libraryExport: 'default', // root export is widget's "export default"
    filename: '[name].js',
    path: path.resolve(__dirname, 'dist/umd')
  },
  module: {
    // noParse: [],
    rules: [
      // JavaScript / ES6
      {
        test: /\.jsx?$/,
        include: path.resolve('./src'),
        loader: 'babel-loader'
      },
      {
        test: /\.scss$/,
        loaders: [
          'style-loader',
          {
            loader: 'css-loader',
            options: {
              modules: true,
              localIdentName: '[local]--[hash:base64:5]'
            }
          },
          'sass-loader'
        ],
        include: path.resolve('./src')
      },
      {
        test: /\.(png|jpg|jpeg|gif|svg)$/,
        loader: 'url-loader',
        query: {
          limit: 8192,
          name: 'images/[name].[ext]?[hash]'
        }
      }
    ]
  }
};

@@ -580,24 +580,27 @@
 : 'umd',%0A   
+ //
  libraryExpo

fix script tag build for new export format