-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
99 lines (92 loc) · 3.56 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
var concat = require('gulp-concat'),
gulp = require('gulp'),
less = require('gulp-less'),
uglify = require('gulp-uglify'),
ngAnnotate = require('gulp-ng-annotate'),
browserSync = require('browser-sync').create(),
cleanCSS = require('gulp-clean-css'),
gulpNgConfig = require('gulp-ng-config');
// Generate a constant file for the app conf
gulp.task('conf', function () {
gulp.src('conf/conf.json')
.pipe(gulpNgConfig('eResources.config', {
environment: 'local'
}))
.pipe(gulp.dest('js/'))
});
// Concat and minify all JS libraries
gulp.task('js', function() {
return gulp.src([
'bower_components/jquery/dist/jquery.min.js',
'bower_components/angular/angular.min.js',
'bower_components/angular-aria/angular-aria.min.js',
'bower_components/angular-animate/angular-animate.min.js',
'bower_components/angular-material/angular-material.min.js',
'bower_components/angular-route/angular-route.min.js',
'bower_components/elasticsearch/elasticsearch.angular.js',
'bower_components/elastic.js/dist/elastic.min.js',
'bower_components/angular-translate/angular-translate.min.js',
'bower_components/angular-translate-loader-url/angular-translate-loader-url.min.js',
'bower_components/angular-translate-loader-static-files/angular-translate-loader-static-files.min.js',
'bower_components/angular-sanitize/angular-sanitize.min.js',
'bower_components/angulartics/dist/angulartics.min.js',
'bower_components/angulartics-google-analytics/dist/angulartics-ga.min.js',
'js/app.js',
'js/conf.js',
'js/directives.js',
'js/elasticui.min.js',
'js/filters.js',
'js/services.js',
'views/resource.js',
'views/resources.js',
'views/subjects.js',
'views/welcome.js'
],
{base: 'bower_components/'}
)
.pipe(concat('all.min.js'))
.pipe(ngAnnotate())
.pipe(uglify())
.pipe(gulp.dest('dist/js'));
});
// Compile less file into CSS
gulp.task('less', function() {
return gulp.src('css/*.less')
.pipe(less())
.pipe(gulp.dest('css'))
.pipe(browserSync.stream());
});
// Concat and minify all CSS files
gulp.task('css', ['less'], function() {
return gulp.src([
'bower_components/angular-material/angular-material.min.css',
'bower_components/material-design-icons/iconfont/material-icons.css',
'css/app.css'
])
.pipe(concat('all.min.css'))
.pipe(cleanCSS())
.pipe(gulp.dest('dist/css'));
});
// Copy one image and the fonts into the assets folder
gulp.task('assets', function() {
// Translation files
gulp.src('languages/*.json')
.pipe(gulp.dest('dist/languages'));
// Angular Material fonts
gulp.src([
'bower_components/material-design-icons/iconfont/MaterialIcons-Regular.woff',
'bower_components/material-design-icons/iconfont/MaterialIcons-Regular.woff2',
'bower_components/material-design-icons/iconfont/MaterialIcons-Regular.ttf',
'fonts/georgia.ttf'
]).pipe(gulp.dest('dist/css'));
});
// Launch server with livereload
gulp.task('serve', function() {
browserSync.init({ server: '.' });
gulp.watch(['js/*.js', 'views/*.js'], ['js']);
gulp.watch('css/app.less', ['css']);
gulp.watch(['languages/*.json'], ['assets']);
gulp.watch(['partials/*.html', 'views/*.html', 'dist/**/*']).on('change', browserSync.reload);
});
// Default task that generate conf file, launch concat js and css, then copy some assets and launch the server with livereload
gulp.task('default', ['conf', 'js', 'css', 'assets', 'serve']);