-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
48 lines (41 loc) · 1.46 KB
/
gulpfile.js
File metadata and controls
48 lines (41 loc) · 1.46 KB
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
var gulp = require('gulp');
var uglify = require('gulp-uglify');
var concat = require('gulp-concat');
var plumber = require('gulp-plumber');
var sourcemaps = require('gulp-sourcemaps');
var templateCache = require('gulp-angular-templatecache');
var packageInfo = require('./package.json');
var htmlFileList = ['src/**/*.html'];
var jsFileList = ['src/**/*.js'];
var libraryFiles = ['src/module.js', 'dist/templates.js'].concat(jsFileList);
var watchedFileList = htmlFileList.concat(jsFileList);
gulp.task('templates', function() {
return gulp.src(htmlFileList)
.pipe(plumber())
.pipe(templateCache('templates.js', {
module: packageInfo.angularModuleName,
}))
.pipe(gulp.dest('./dist/'));
});
gulp.task('build-nomin', ['templates'], function() {
return gulp.src(libraryFiles)
.pipe(plumber())
.pipe(sourcemaps.init())
.pipe(concat(packageInfo.name + '.js'))
.pipe(sourcemaps.write())
.pipe(gulp.dest('./dist/'));
});
gulp.task('build-min', ['templates'], function() {
return gulp.src(libraryFiles)
.pipe(plumber())
.pipe(sourcemaps.init())
.pipe(concat(packageInfo.name + '.min.js'))
.pipe(uglify())
.pipe(sourcemaps.write())
.pipe(gulp.dest('./dist/'));
});
gulp.task('build', ['build-nomin', 'build-min']);
gulp.task('watch', ['build'], function() {
return gulp.watch(watchedFileList, ['build']);
});
gulp.task('default', ['watch']);