text: /* global __dirname, require, module */
  
  const path = require('path');
  const { mode } = require('yargs').argv; // use --env with webpack 2
  const pkg = require('./package.json');
  
  const libraryName = pkg.name;
  const isProduction = mode === 'production';
  
  let outputFile;
  
  if (isProduction) {
    outputFile = `${libraryName}.min.js`;
  } else {
    outputFile = `${libraryName}.js`;
  }
  
  const config = {
    entry: `${__dirname}/src/Calculator.js`,
    target: 'node',
    devtool: isProduction ? false : 'source-map',
    output: {
      path: `${__dirname}/lib`,
      filename: outputFile,
      library: libraryName,
      libraryTarget: 'umd',
      umdNamedDefine: true,
      globalObject: 'this',
    },
    module: {
      rules: [
        {
          test: /\.js$/i,
          loader: 'babel-loader',
          exclude: /(node_modules|bower_components)/,
          options: {
            presets: ['env'],
          },
        },
        {
          test: /\.js$/i,
          loader: 'eslint-loader',
          exclude: /node_modules/,
        },
      ],
    },
    resolve: {
      modules: [path.resolve('./node_modules'), path.resolve('./src')],
      extensions: ['.json', '.js'],
    },
  };
  
  module.exports = config;
  