-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
58 lines (51 loc) · 1.51 KB
/
gulpfile.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
const gulp = require('gulp');
const plugins = require('gulp-load-plugins')();
const babel = require('rollup-plugin-babel');
const runSequence = require('run-sequence');
const karma = require('karma');
gulp.task('build', () => gulp
.src('src/index.js')
.pipe(plugins.plumber())
.pipe(plugins.sourcemaps.init())
.pipe(plugins.sourcemaps.identityMap())
.pipe(plugins.betterRollup({
external: ['angular'],
globals: ['angular'],
plugins: [
babel({ exclude: 'node_modules/**' }),
],
}, {
moduleName: 'ngEasyDropdown',
format: 'umd',
globals: {
angular: 'angular',
},
}))
.pipe(plugins.sourcemaps.write())
.pipe(plugins.rename('ng-easy-dropdown.js'))
.pipe(gulp.dest('dist')));
gulp.task('minify', () => gulp
.src(['dist/*.js', '!dist/*.min.js'])
.pipe(plugins.sourcemaps.init({ loadMaps: true }))
.pipe(plugins.sourcemaps.identityMap())
.pipe(plugins.uglify({
source_map: true,
}))
.pipe(plugins.rename((path) => {
// eslint-disable-next-line no-param-reassign
path.extname = `.min${path.extname}`;
}))
.pipe(plugins.sourcemaps.write('.'))
.pipe(gulp.dest('dist')));
gulp.task('dist', cb => runSequence('clean', 'build', 'minify', cb));
gulp.task('clean', () => gulp
.src('dist')
.pipe(plugins.clean()));
gulp.task('test', (done) => {
new karma.Server({
configFile: __dirname + '/karma.conf.js',
singleRun: true,
}, done).start();
});
gulp.task('watch', () => gulp.watch('src/*.js', ['build']));
gulp.task('default', ['build', 'watch']);