-
Notifications
You must be signed in to change notification settings - Fork 6
/
gulpfile.babel.js
141 lines (125 loc) · 4.27 KB
/
gulpfile.babel.js
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
import gulp from 'gulp';
import del from 'del';
import sourcemaps from 'gulp-sourcemaps';
import eslint from 'gulp-eslint';
import babel from 'gulp-babel';
import rename from 'gulp-rename';
import minifyCss from 'gulp-minify-css';
import uglify from 'gulp-uglify';
import header from 'gulp-header';
import esdoc from 'gulp-esdoc';
import concat from 'gulp-concat';
import mochaPhantomJS from 'gulp-mocha-phantomjs';
import iife from 'gulp-iife';
const banner = `/*
* This file/code is part of Paper UI project.
*
* Paper UI - is a modern front-end framework based on Material Design by Google
* https://github.com/virtyaluk/paper-ui
*
* Copyright (c) 2015 Bohdan Shtepan
* http://modern-dev.com/
*
* Licensed under the MIT license.
*/
`,
jsSource = ['src/js/ElementRect.js', 'src/js/PaperWave.js', 'src/js/PaperRipple.js'],
main = 'PaperRipple.js';
gulp.task('lint', () =>
gulp.src(['src/js/*.js', 'gulpfile.babel.js'])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError())
);
gulp.task('clean', () => del(['dist/', 'docs/']));
gulp.task('transpile-js:umd', () =>
gulp.src(jsSource)
.pipe(concat(main))
.pipe(sourcemaps.init())
.pipe(babel({
presets: ['es2015'],
plugins: ['transform-class-properties', 'transform-es2015-modules-umd'],
moduleIds: true
}))
.pipe(sourcemaps.write('.'))
.pipe(header(banner))
.pipe(gulp.dest('dist'))
);
gulp.task('minify-js:umd', ['transpile-js:umd'], () =>
gulp.src('dist/PaperRipple.js')
.pipe(sourcemaps.init())
.pipe(uglify())
.pipe(sourcemaps.write('.'))
.pipe(header(banner))
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest('dist'))
);
gulp.task('transpile-js:systemjs', () =>
gulp.src(jsSource)
.pipe(concat(main))
.pipe(sourcemaps.init())
.pipe(babel({
presets: ['es2015'],
plugins: ['transform-class-properties', 'transform-es2015-modules-systemjs'],
moduleIds: true
}))
.pipe(sourcemaps.write('.'))
.pipe(header(banner))
.pipe(gulp.dest('dist/systemjs'))
);
gulp.task('minify-js:systemjs', ['transpile-js:systemjs'], () =>
gulp.src('dist/systemjs/PaperRipple.js')
.pipe(sourcemaps.init())
.pipe(uglify())
.pipe(sourcemaps.write('.'))
.pipe(header(banner))
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest('dist/systemjs'))
);
gulp.task('styles', ['clean'], () =>
gulp.src('src/css/*.css')
.pipe(sourcemaps.init())
.pipe(minifyCss())
.pipe(sourcemaps.write('.'))
.pipe(header(banner))
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest('dist'))
);
gulp.task('docs', ['lint'], () => gulp.src('./src').pipe(esdoc()));
gulp.task('transpile-js:jquery-plugin', () =>
gulp.src(['src/js/ElementRect.js', 'src/js/PaperWave.js', 'src/js/PaperRipple.js', 'src/js/paperRipple.jquery.js'])
.pipe(concat('paperRipple.jquery.js'))
.pipe(sourcemaps.init())
.pipe(babel({
presets: ['es2015'],
plugins: ['transform-class-properties']
}))
.pipe(sourcemaps.write('.'))
.pipe(iife({
useStrict: false,
params: ['window', '$', 'module'],
args: ['window', 'jQuery', '{}']
}))
.pipe(header(banner))
.pipe(gulp.dest('dist'))
);
gulp.task('minify-js:jquery-plugin', ['transpile-js:jquery-plugin'], () =>
gulp.src('dist/paperRipple.jquery.js')
.pipe(sourcemaps.init())
.pipe(uglify())
.pipe(sourcemaps.write('.'))
.pipe(header(banner))
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest('dist'))
);
gulp.task('scripts', ['clean', 'minify-js:systemjs', 'minify-js:umd', 'minify-js:jquery-plugin']);
gulp.task('test', ['scripts', 'styles'], () => gulp.src('test/runner.html').pipe(mochaPhantomJS({ reporter: 'spec' })));
gulp.task('test:ci', ['scripts', 'styles'], () =>
gulp.src('test/runner.html')
.pipe(mochaPhantomJS({
reporter: 'xunit',
output: 'test/results/result.xml'
}))
);
gulp.task('ci', ['lint', 'test:ci']);
gulp.task('default', ['clean', 'lint', 'scripts', 'styles', 'docs', 'test']);