summaryrefslogtreecommitdiff
path: root/gulpfile.js
blob: 3e1a65a055cd3affc1fe874dd07be05a2b4ccd5b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/* eslint-env node */
var gulp = require('gulp');
var eslint = require('gulp-eslint');
var sass = require('gulp-sass');
var rename = require('gulp-rename');
var autoprefixer = require('gulp-autoprefixer');
var csso = require('gulp-csso');
var size = require('gulp-size');
var uglify = require('gulp-uglify');
var webpack = require('webpack-stream');

gulp.task('style', function () {
    return gulp.src('./style/touch-imagelightbox.scss')
        .pipe(sass({
            outputStyle: 'compressed'
        }).on('error', sass.logError))
        .pipe(gulp.dest('./demo'));
});

var webpackOptions = {
    entry: {
        ActivityIndicator: './src/Plugins/ActivityIndicator.js',
        Overlay: './src/Plugins/Overlay.js',
        CloseButton: './src/Plugins/CloseButton.js',
        Core: './src/LightBox.js'
    },
    output: {
        filename: "LightBox.[name].js",
        library: ["LightBox", "[name]"],
        libraryTarget: "var"
    },
    module: {
        loaders: [
            {
                loader: 'babel',
                query: {
                    presets: ['es2015']
                }
            }
        ]
    }
};

gulp.task('pack', function() {
    return gulp.src('').pipe(webpack(webpackOptions)).pipe(gulp.dest('./demo'));

    //return gulp.src(['./src/LightBox.js', './src/Plugins/*.js'])
    //    .pipe(webpack(webpackOptions))
    //    //.pipe(gulp.dest('./dist'));
    //    .pipe(gulp.dest('./demo'));
});

gulp.task('default', ['pack']);

gulp.task('watch', function () {
    //gulp.watch('./src/LightBox.js', ['pack'])

    webpackOptions.watch = true;

    gulp.src('').pipe(webpack(webpackOptions)).pipe(gulp.dest('./demo'));

    //return gulp.src(['./src/LightBox.js', './src/Plugins/*.js'])
    //    .pipe(webpack(webpackOptions))
    //    //.pipe(gulp.dest('./dist'));
    //    .pipe(gulp.dest('./demo'));
});