text: /* eslint-disable */
  const webpack = require('webpack');
  const path = require('path');
  const env = require('yargs').argv.env; // use --env with webpack 2
  const pkg = require('./package.json');
  
  let libraryName = 'webpack';
  
  let outputFile, mode;
  
  if (env === 'build') {
    mode = 'production';
    outputFile = libraryName + '.min.js';
  } else {
    mode = 'development';
    outputFile = libraryName + '.js';
  }
  
  const config = {
    mode: mode,
    entry: __dirname + '/src/index.ts',
    devtool: 'source-map',
    output: {
      path: __dirname + '/dist',
      filename: outputFile,
      libraryTarget: 'umd',
      umdNamedDefine: true,
    },
    module: {
      rules: [
        {
          test: /(\.jsx|\.js\.ts|\.tsx)$/,
          loader: 'babel-loader',
          exclude: /(node_modules|bower_components)/,
        },
        {
          test: /(\.ts|\.tsx)$/,
          loader: 'ts-loader',
          exclude: /(node_modules|bower_components)/,
        },
        {
          test: /\.(pdf|jpg|png|gif|svg|ico)$/,
          use: [
            {
              loader: 'url-loader',
            },
          ],
        },
        {
          test: /\.css$/,
          use: ['style-loader', 'postcss-loader'],
        },
      ],
    },
    resolve: {
      modules: [path.resolve('./node_modules'), path.resolve('./src')],
      alias: {
        'rsg-components': path.join(
          __dirname,
          'node_modules/react-styleguidist/lib/client/rsg-components/',
        ),
      },
      extensions: ['.json', '.js', '.ts', '.tsx'],
    },
    externals: {
      react: 'React',
    },
  };
  
  module.exports = config;
  