This repository has been archived by the owner on Feb 17, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgulpfile.js
83 lines (76 loc) · 2.16 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
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
var gulp = require('gulp');
var sass = require('gulp-sass');
var ngAnnotate = require('gulp-ng-annotate');
var uglify = require('gulp-uglify');
var eslint = require('gulp-eslint');
var rename = require('gulp-rename');
var header = require('gulp-header');
var templateCache = require('gulp-angular-templatecache');
var minifyHtml = require('gulp-minify-html');
var concat = require('gulp-concat');
var addsrc = require('gulp-add-src');
var order = require('gulp-order');
var packageName = 'notification';
var protractor = require('gulp-protractor').protractor;
var pkg = require('./package.json');
var banner = ['/**',
' * <%= pkg.name %> - <%= pkg.description %>',
' * @author <%= pkg.author %>',
' * @version v<%= pkg.version %>',
' * @link <%= pkg.homepage %>',
' * @license <%= pkg.license %>',
' */',
''].join('\n');
// ==== Styles
gulp.task('styles', function () {
gulp.src('src/*.scss')
.pipe(header(banner, { pkg: pkg }))
.pipe(rename({
basename: packageName
}))
.pipe(gulp.dest('dist'))
.pipe(sass().on('error', sass.logError))
.pipe(rename({
suffix: '.min'
}))
.pipe(gulp.dest('dist'))
.pipe(gulp.dest('demo'));
});
// ====== Templates
gulp.task('templates', function () {
gulp.src(['*.html'], { cwd: 'src' })
.pipe(minifyHtml({
empty: true,
spare: true,
quotes: true
}))
.pipe(templateCache({
module: packageName
}))
.pipe(rename([packageName, '.templates.js'].join('')))
.pipe(gulp.dest('build'));
});
gulp.task('service', function () {
gulp.src(['src/*.js'])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError())
.pipe(ngAnnotate())
.pipe(addsrc('build/*.js'))
.pipe(order([
'src/*.js',
'build/notification.templates.js'
], { base: './' }))
.pipe(concat([packageName, '.js'].join('')))
.pipe(header(banner, { pkg: pkg }))
.pipe(gulp.dest('dist'))
.pipe(uglify())
.pipe(rename({
suffix: '.min'
}))
.pipe(header(banner, { pkg: pkg }))
.pipe(gulp.dest('dist'))
.pipe(gulp.dest('demo'));
});
gulp.task('build', ['templates', 'service', 'styles']);
gulp.task('default', ['build'], function () {});