var gulp    = require("gulp"),
    mocha   = require("gulp-mocha"),
    webpack = require("gulp-webpack");

var packageInfo = require("./package.json");
var banner = "eV\ncopyright (c) 2014 Susisu | MIT License\nhttps://github.com/susisu/eV";

gulp.task("test", function () {
    return gulp.src("./test/ev.js")
        .pipe(mocha());
});

gulp.task("webpack", function () {
    return gulp.src("./lib/ev.js")
        .pipe(webpack({
            "output": {
                "libraryTarget": "this",
                "library": "ev",
                "sourcePrefix": "    ",
                "filename": "ev." + packageInfo.version + ".js"
            },
            "plugins": [
                new webpack.webpack.BannerPlugin(
                    banner,
                    { "entryOnly": true }
                )
            ]
        }))
        .pipe(gulp.dest("./build"));
});

gulp.task("webpack-min", function () {
    return gulp.src("./lib/ev.js")
        .pipe(webpack({
            "output": {
                "libraryTarget": "this",
                "library": "ev",
                "sourcePrefix": "    ",
                "filename": "ev." + packageInfo.version + ".min.js",
            },
            "plugins": [
                new webpack.webpack.optimize.UglifyJsPlugin(),
                new webpack.webpack.BannerPlugin(
                    banner,
                    { "entryOnly": true }
                )
            ]
        }))
        .pipe(gulp.dest("./build"));
});

gulp.task("build", ["webpack", "webpack-min"]);

gulp.task("default", ["build"]);

@@ -478,36 +478,35 @@
 ibraryTarget%22: %22
-this
+var
 %22,%0A             
@@ -513,33 +513,43 @@
    %22library%22: %22e
-v
+lectronvolt
 %22,%0A             
@@ -1045,12 +1045,11 @@
 %22: %22
-this
+var
 %22,%0A 
@@ -1076,17 +1076,27 @@
 ary%22: %22e
-v
+lectronvolt
 %22,%0A     

Change build settings