function baseConfig(name, mode) {
  const config = {
    name: `${name}-${mode}`,
    mode,
    output: {
      library: 'cloudinary',
      libraryTarget: 'umd',
      globalObject: "this",
      pathinfo: false
    },
    optimization: {
      concatenateModules: true,
      moduleIds: 'named',
      usedExports: true,
      minimizer: [new TerserPlugin({
        terserOptions: {
          mangle: {
            keep_classnames: true,
            reserved: reserved,
            ie8: true
          }
        },
      })]
    },
    resolve: {
      extensions: ['.js']
    },
    externals: [
      {
        jquery: 'jQuery'
      }
    ],
    node: {
      Buffer: false,
      process: false
    },
    devtool: "source-map",
    module: {
      rules: [
        {
          test: /\.m?js$/,
          exclude: /(node_modules|bower_components)/,
          use: {loader: 'babel-loader'}
        }
      ]
    },
    plugins: [
      new webpack.BannerPlugin({
        banner: `/**
   * cloudinary-[name].js
   * Cloudinary's JavaScript library - Version ${version}
   * Copyright Cloudinary
   * see https://github.com/cloudinary/cloudinary_js
   *
   */`, // the banner as string or function, it will be wrapped in a comment
        raw: true, // if true, banner will not be wrapped in a comment
        entryOnly: true, // if true, the banner will only be added to the entry chunks
      })
    ]
  };

  let filename = `cloudinary-${name}`;
  if(mode === 'production') { filename += '.min';}

  const util = name.startsWith('jquery') ? 'jquery' : 'lodash';
  const utilPath = path.resolve(__dirname, `src/util/${util}`);

  config.output.filename = `./${filename}.js`;
  config.entry = `./src/namespace/cloudinary-${name}.js`;
  config.resolve.alias = {
    "../util$": utilPath,
    "./util$": utilPath
  };
  // Add reference to each lodash function as a separate module.
  if (name === 'core') {
    config.externals.push(resolveLodash);
  }
  config.plugins.push(
    new BundleAnalyzerPlugin({
      analyzerMode: 'static',
      reportFilename: `./${filename}-visualizer.html`,
      openAnalyzer: false
    })
  );
  return config;
}
function baseConfig(name, mode) {
  const config = {
    name: `${name}-${mode}`,
    mode,
    output: {
      library: 'cloudinary',
      libraryTarget: 'umd',
      globalObject: "this",
      pathinfo: false
    },
    optimization: {
      concatenateModules: true,
      moduleIds: 'named',
      usedExports: true,
      minimizer: [new TerserPlugin({
        terserOptions: {
          mangle: {
            keep_classnames: true,
            reserved: reserved,
            ie8: true
          }
        },
      })]
    },
    resolve: {
      extensions: ['.js']
    },
    externals: [
      {
        jquery: 'jQuery'
      }
    ],
    node: {
      Buffer: false,
      process: false
    },
    devtool: "source-map",
    module: {
      rules: [
        {
          test: /\.m?js$/,
          exclude: /(node_modules|bower_components)/,
          use: {loader: 'babel-loader'}
        }
      ]
    },
    plugins: [
      new webpack.BannerPlugin({
        banner: `/**
   * cloudinary-[name].js
   * Cloudinary's JavaScript library - Version ${version}
   * Copyright Cloudinary
   * see https://github.com/cloudinary/cloudinary_js
   *
   */`, // the banner as string or function, it will be wrapped in a comment
        raw: true, // if true, banner will not be wrapped in a comment
        entryOnly: true, // if true, the banner will only be added to the entry chunks
      })
    ]
  };

  let filename = `cloudinary-${name}`;
  if(mode === 'production') { filename += '.min';}

  const util = name.startsWith('jquery') ? 'jquery' : 'lodash';
  const utilPath = path.resolve(__dirname, `src/util/${util}`);

  config.output.filename = `./${filename}.js`;
  config.entry = `./src/namespace/cloudinary-${name}.js`;
  config.resolve.alias = {
    "../util$": utilPath,
    "./util$": utilPath
  };
  // Add reference to each lodash function as a separate module.
  if (name === 'core') {
    config.externals.push(resolveLodash);
  }
  config.plugins.push(
    new BundleAnalyzerPlugin({
      analyzerMode: 'static',
      reportFilename: `./${filename}-visualizer.html`,
      openAnalyzer: false
    })
  );
  return config;
}
function baseConfig ( name , mode ) { const config = { name : ` ${ name } ${ mode } ` , mode , output : { library : 'cloudinary' , libraryTarget : 'umd' , globalObject : "this" , pathinfo : false } , optimization : { concatenateModules : true , moduleIds : 'named' , usedExports : true , minimizer : [ new TerserPlugin ( { terserOptions : { mangle : { keep_classnames : true , reserved : reserved , ie8 : true } } , } ) ] } , resolve : { extensions : [ '.js' ] } , externals : [ { jquery : 'jQuery' } ] , node : { Buffer : false , process : false } , devtool : "source-map" , module : { rules : [ { test : / \.m?js$ / , exclude : / (node_modules|bower_components) / , use : { loader : 'babel-loader' } } ] } , plugins : [ new webpack . BannerPlugin ( { banner : ` ${ version } ` , // the banner as string or function, it will be wrapped in a comment raw : true , // if true, banner will not be wrapped in a comment entryOnly : true , // if true, the banner will only be added to the entry chunks } ) ] } ; let filename = ` ${ name } ` ; if ( mode === 'production' ) { filename += '.min' ; } const util = name . startsWith ( 'jquery' ) ? 'jquery' : 'lodash' ; const utilPath = path . resolve ( __dirname , ` ${ util } ` ) ; config . output . filename = ` ${ filename } ` ; config . entry = ` ${ name } ` ; config . resolve . alias = { "../util$" : utilPath , "./util$" : utilPath } ; // Add reference to each lodash function as a separate module. if ( name === 'core' ) { config . externals . push ( resolveLodash ) ; } config . plugins . push ( new BundleAnalyzerPlugin ( { analyzerMode : 'static' , reportFilename : ` ${ filename } ` , openAnalyzer : false } ) ) ; return config ; }
Generate a webpack configuration
@param {string} name the name of the package
@param {string} mode either development or production
@return {object} webpack configuration
Generate a webpack configuration