// @flow weak

const path = require("path");
const webpack = require("webpack");
const BundleInspector = require("bundle-inspector-webpack-plugin");

const libraryName = "react-electric-slide";

const baseConfig = {
  entry: {
    [libraryName]: path.join(__dirname, "src/index.js")
  },
  output: {
    path: path.join(__dirname, "build/dist"),
    library: libraryName,
    libraryTarget: "umd",
    umdNamedDefine: true
  },
  externals: [
    {
      react: {
        root: "React",
        commonjs2: "./react",
        commonjs: ["./react"],
        amd: "react"
      }
    }
  ],
  module: {
    loaders: [
      {
        test: /\.js$/,
        loader: "babel-loader",
        exclude: /(node_modules)/,
        query: {
          cacheDirectory: true
        }
      }
    ]
  },
  resolve: {
    modules: [path.resolve(__dirname, "src"), "node_modules"]
  },
  plugins: []
};

let config;

if (process.env.NODE_ENV === "production") {
  config = Object.assign({}, baseConfig, {
    output: Object.assign({}, baseConfig.output, {
      filename: `${libraryName}.min.js`
    }),
    plugins: baseConfig.plugins.concat([
      new webpack.DefinePlugin({
        "process.env.NODE_ENV": JSON.stringify("production")
      }),
      new webpack.optimize.UglifyJsPlugin({
        compress: {
          warnings: false,
          screw_ie8: true
        }
      }),
      new BundleInspector()
    ])
  });
} else {
  config = Object.assign({}, baseConfig, {
    output: Object.assign({}, baseConfig.output, {
      filename: `${libraryName}.js`
    })
  });
}

module.exports = config;

@@ -566,24 +566,186 @@
 ct%22%0A      %7D%0A
+    %7D,%0A    %7B%0A      %22react-dom%22: %7B%0A        root: %22ReactDOM%22,%0A        commonjs2: %22./react-dom%22,%0A        commonjs: %5B%22./react-dom%22%5D,%0A        amd: %22react-dom%22%0A      %7D%0A
     %7D%0A  %5D,%0A 

add react-dom to externals