-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
68 lines (61 loc) · 1.99 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
/*jshint strict:false */
var gulp = require('gulp');
var gulpif = require('gulp-if');
var argv = require('yargs').argv;
var concat = require('gulp-concat');
var ngAnnotate = require('gulp-ng-annotate');
var templateCache = require('gulp-angular-templatecache');
var autoprefixer = require('gulp-autoprefixer');
var sass = require('gulp-sass');
var csso = require('gulp-csso');
var buffer = require('vinyl-buffer');
var uglify = require('gulp-uglify');
var sourcemaps = require('gulp-sourcemaps');
var plumber = require('gulp-plumber');
var Server = require('karma').Server;
gulp.task('sass', function() {
return gulp.src('app/src/sass-theme/main.scss')
.pipe(plumber())
.pipe(sass())
.pipe(autoprefixer())
.pipe(gulpif(argv.production, csso()))
.pipe(gulp.dest('public/css'));
});
gulp.task('angular', function() {
return gulp.src([
'app/src/app.js',
'app/src/components/**/*.js',
'app/src/services/*.js'
])
.pipe(concat('application.js'))
.pipe(ngAnnotate())
.pipe(gulpif(argv.production, uglify()))
.pipe(gulp.dest('public/js'));
});
gulp.task('templates', function() {
return gulp.src('app/src/components/**/*.html')
.pipe(templateCache({ root: 'components', module: 'MyApp' }))
.pipe(gulpif(argv.production, uglify()))
.pipe(gulp.dest('public/js'));
});
gulp.task('vendor', function() {
return gulp.src('app/src/vendor/*.js')
.pipe(gulpif(argv.production, uglify()))
.pipe(gulp.dest('public/js/lib'));
});
gulp.task('watch', function() {
gulp.watch(['app/src/sass-theme/**/*.scss', 'app/src/components/**/*.scss'], ['sass']);
gulp.watch('app/src/components/**/*.html', ['templates']);
gulp.watch('app/src/**/*.js', ['angular']);
});
/**
* Run test once and exit
*/
gulp.task('test', function (done) {
new Server({
configFile: __dirname + '/app/karma.conf.js',
singleRun: true
}, done).start();
});
gulp.task('build', ['sass', 'angular', 'vendor', 'templates']);
gulp.task('default', ['build', 'watch']);