const path = require('path')
const MinifyPlugin = require("babel-minify-webpack-plugin");

module.exports = (env) => {
  let plugins = []
  if (env === 'production')
    plugins = [new MinifyPlugin()];

  return {
    entry: './src/index.ts',
    module: {
      rules: [
        {
          test: /\.tsx?$/,
          loader: 'ts-loader',
          exclude: /node_modules/
        },
        {
          test: /\.css$/,
          use: [
            {
              loader: 'style-loader'
            },
            {
              loader: 'css-loader',
              options: {
                modules: true,
              }
            }
          ]
        }
      ]
    },
    resolve: {
      extensions: [ ".ts", ".js" ]
    },
    output: {
      filename: 'index.js',
      path: path.resolve(__dirname, 'dist'),
      libraryTarget: "umd"
    },
    plugins
  }
};

@@ -82,16 +82,52 @@
 lugin%22);
+%0Aconst webpack = require('webpack');
 %0A%0Amodule
@@ -194,16 +194,18 @@
 uction')
+ %7B
 %0A    plu
@@ -212,16 +212,129 @@
 gins = %5B
+%0A      new webpack.DefinePlugin(%7B%0A          'process.env.NODE_ENV': JSON.stringify('production')%0A      %7D),%0A      
 new Mini
@@ -347,10 +347,21 @@
 in()
-%5D;
+%0A    %5D;%0A  %7D%0A%0A
 %0A%0A  

define environment