forked from hackathonovo/kalvarija
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
64 lines (53 loc) · 1.86 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
var gulp = require('gulp');
var sass = require('gulp-sass');
var minifyCss = require('gulp-minify-css');
var autoprefixer = require('gulp-autoprefixer');
var concat = require('gulp-concat');
var inject = require('gulp-inject');
var angularFilesort = require('gulp-angular-filesort');
var nodemon = require('gulp-nodemon');
var paths = {
sass_entry: ['./frontend/content/css/main.scss'],
sass: ['./frontend/content/css/**/*.scss'],
app: ['./frontend/**/*.js']};
var index = gulp.src('./frontend/index.html');
gulp.task('sass', function(done) {
gulp.src(paths.sass_entry)
.pipe(sass())
.on('error', sass.logError)
.pipe(autoprefixer({
browsers: ['last 2 versions'],
cascade: false
}))
.pipe(minifyCss({
keepSpecialComments: 0
}))
.pipe(gulp.dest('./frontend/dist/css/'))
.on('end', done);
});
gulp.task('inject', function() {
var app = gulp.src(paths.app);
//angularFilesort() is called twice because of a bug - https://github.com/klei/gulp-angular-filesort/issues/44
return index.pipe(inject(app.pipe(angularFilesort()).pipe(angularFilesort()), {ignorePath: 'frontend'}))
.pipe(gulp.dest('./frontend/'));
})
gulp.task('bundle-app', function () {
gulp.src(paths.app.pipe(angularFilesort()))
.pipe(concat('app.js'))
.pipe(uglify())
.pipe(gulp.dest('./frontend/dist/js'));
index.pipe(inject('./frontend/dist/js/app.js', {ignorePath: 'frontend'}))
.pipe(gulp.dest('.frontend/'));
});
gulp.task('server',function(){
nodemon({
script: 'server.js',
ignore: 'frontend/*'
});
});
gulp.task('watch', function () {
gulp.watch(paths.sass, ['sass']);
gulp.watch(paths.app, ['inject']);
});
gulp.task('build', ['inject', 'sass', 'server']);
gulp.task('default', ['inject', 'sass', 'watch']);