const webpack = require("webpack");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const failPlugin = require("webpack-fail-plugin");
const uglifySaveLicense = require("uglify-save-license");

const isProduction = process.env.NODE_ENV === "production";

let common = {
    devtool: isProduction
        ? null
        : "#inline-eval-source-map",
    plugin: isProduction
        ? [failPlugin]
        : [],
    resolve: { extensions: ["", ".ts", ".tsx", ".js"] },
    ts: { compilerOptions: { "sourceMap": !isProduction } }
};

module.exports = [
    Object.assign({},
        common,
        {
            entry: {
                index: ["babel-polyfill", "./src/public/js/index.ts"]
            },
            module: {
                loaders: [{
                    test: /\.tsx?$/,
                    loader: "babel-loader?presets[]=es2015!ts-loader"
                }]
            },
            output: {
                filename: "lib/public/js/[name].js"
            },
            plugins: common.plugin.concat([
                new CopyWebpackPlugin(
                    [{ from: "src/public/", to: "lib/public/" }],
                    {
                        ignore: [
                            "test/",
                            "*.ts",
                            "*.tsx"
                        ]
                    }),
            ])
                .concat(isProduction
                    ? [
                        new webpack.optimize.UglifyJsPlugin({
                            output: { comments: uglifySaveLicense }
                        })
                    ]
                    : [])
        }
    ),
    Object.assign({},
        common,
        {
            entry: {
                index: ["babel-polyfill", "./src/index.ts"],
                "test/test": ["babel-polyfill", "./src/test/test.ts"]
            },
            externals: /^(?!\.)/,
            module: {
                loaders: [{
                    test: /\.tsx?$/,
                    loader: "babel-loader?presets[]=modern-node!ts-loader"
                }]
            },
            output: {
                filename: "lib/[name].js",
                libraryTarget: "commonjs2"
            }
        }
    )
];

@@ -747,34 +747,207 @@
       loaders: %5B
-%7B
 %0A
+                    %7B%0A                        test: /%5C.js$/,%0A                        loader: %22babel-loader?presets%5B%5D=es2015%22%0A                    %7D,%0A                    %7B%0A    
                 
@@ -959,32 +959,36 @@
 est: /%5C.tsx?$/,%0A
+    
                 
@@ -1049,33 +1049,54 @@
                 
-%7D
+    %7D%0A                
 %5D%0A            %7D,

Fix bulid