This repository has been archived by the owner on Oct 26, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
gulpfile.js
90 lines (73 loc) · 2.17 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
var gulp = require('gulp'),
del = require('del'),
prefix = require('gulp-prefix'),
less = require('gulp-less'),
replace = require('gulp-replace'),
htmlReplace = require('gulp-html-replace'),
browserSync = require('browser-sync'),
reload = browserSync.reload,
sourcemaps = require('gulp-sourcemaps');
// CLEAN
gulp.task('clean', function(cb) {
del(['src/plone/app/angularjs/app/**/*.*'], cb)
});
// TEMPLATES
gulp.task('templates', function(){
gulp.src('app/*.tpl.html')
.pipe(gulp.dest('src/plone/app/angularjs/app'))
.pipe(reload({stream:true}));
});
// BOWER_COMPOMENTS
gulp.task('bower', function(){
gulp.src('app/bower_components/**/*.*')
.pipe(gulp.dest('src/plone/app/angularjs/app/bower_components'))
.pipe(reload({stream:true}));
});
// INDEX.HTML
gulp.task('index-html', function(){
var prefixUrl = "++theme++plone.app.angularjs/";
gulp.src('app/index.html')
.pipe(prefix(prefixUrl, null, true))
.pipe(htmlReplace({
'mock': ''
}))
.pipe(gulp.dest('src/plone/app/angularjs/app'))
.pipe(reload({stream:true}));
});
// SCRIPTS
gulp.task('scripts', function(){
gulp.src('app/scripts/**/*.js')
.pipe(replace("templateUrl: '", "templateUrl: '++theme++plone.app.angularjs/"))
.pipe(gulp.dest('src/plone/app/angularjs/app/scripts/'))
.pipe(reload({stream:true}));
});
// STYLES
gulp.task('styles', function(){
gulp.src('app/styles/*.less')
.pipe(sourcemaps.init())
.pipe(less())
.pipe(sourcemaps.write())
.pipe(gulp.dest('app/styles/'))
.pipe(gulp.dest('src/plone/app/angularjs/app/styles/'))
.pipe(reload({stream:true}));
});
// WATCH
gulp.task('watch', ['browser-sync'], function() {
gulp.watch('app/styles/**/*.less', ['styles']);
gulp.watch('app/scripts/**/*.js', ['scripts']);
//gulp.watch('app/images/**/*', ['images']);
gulp.watch('app/*.tpl.html', ['templates']);
gulp.watch('app/index.html', ['index-html']);
});
// BROWSER SYNC
gulp.task('browser-sync', function() {
browserSync({
server: {
baseDir: "./app/"
}
});
});
// DEFAULT
gulp.task('default', ['clean'], function() {
gulp.start('bower', 'templates', 'index-html', 'scripts', 'styles');
});