Skip to content

Commit 05b6220

Browse files
committed
Added Gulp tasks to template developement
1 parent 3fc7d2d commit 05b6220

File tree

1 file changed

+113
-0
lines changed
  • joomla-gulp-extensions/templates/frontend

1 file changed

+113
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
var gulp = require('gulp');
2+
3+
var config = require('../../../gulp-config.json');
4+
5+
var extPath = './extensions/templates/frontend/base';
6+
var cssPath = extPath + '/css';
7+
var lessPath = extPath + '/less';
8+
var jsPath = extPath + '/js';
9+
10+
// Dependencies
11+
var browserSync = require('browser-sync');
12+
var minifyCSS = require('gulp-minify-css');
13+
var rename = require('gulp-rename');
14+
var del = require('del');
15+
var vinylPaths = require('vinyl-paths');
16+
var less = require('gulp-less');
17+
var uglify = require('gulp-uglify');
18+
var concat = require('gulp-concat');
19+
var zip = require('gulp-zip');
20+
21+
// Clean
22+
gulp.task('clean:templates.frontend.base', function() {
23+
return gulp.src(config.wwwDir + '/templates/base', { read: false })
24+
.pipe(vinylPaths(del));
25+
});
26+
27+
// Copy
28+
gulp.task('copy:templates.frontend.base',
29+
[
30+
'copy:templates.frontend.base:template'
31+
],
32+
function() {
33+
});
34+
35+
// Copy template
36+
gulp.task('copy:templates.frontend.base:template', ['clean:templates.frontend.base'], function() {
37+
return gulp.src([
38+
extPath + '/**'
39+
])
40+
.pipe(gulp.dest(config.wwwDir + '/templates/base'));
41+
});
42+
43+
// Less
44+
gulp.task('less:templates.frontend.base', function () {
45+
return gulp.src(lessPath + '/style.less')
46+
.pipe(less())
47+
.pipe(gulp.dest(cssPath))
48+
.pipe(gulp.dest(config.wwwDir + '/templates/base/css'))
49+
.pipe(minifyCSS({keepSpecialComments: '0'}))
50+
.pipe(rename(function (path) {
51+
path.basename += '.min';
52+
}))
53+
.pipe(gulp.dest(cssPath))
54+
.pipe(gulp.dest(config.wwwDir + '/templates/base/css'));
55+
});
56+
57+
// Compile scripts
58+
gulp.task('scripts:templates.frontend.base', function () {
59+
return gulp.src([
60+
jsPath + '/**/*.js',
61+
'!' + jsPath + '/**/*.min.js'
62+
])
63+
.pipe(gulp.dest(config.wwwDir + '/templates/base/js'))
64+
.pipe(uglify())
65+
.pipe(rename(function (path) {
66+
path.basename += '.min';
67+
}))
68+
.pipe(gulp.dest(jsPath))
69+
.pipe(gulp.dest(config.wwwDir + '/templates/base/js'));
70+
});
71+
72+
// Watch
73+
gulp.task('watch:templates.frontend.base',
74+
[
75+
'watch:templates.frontend.base:template',
76+
'watch:templates.frontend.base:scripts',
77+
'watch:templates.frontend.base:less'
78+
],
79+
function() {
80+
});
81+
82+
// Watch: Template
83+
gulp.task('watch:templates.frontend.base:template', function() {
84+
gulp.watch([
85+
extPath + '/**',
86+
'!' + lessPath,
87+
'!' + lessPath + '/**',
88+
'!' + jsPath,
89+
'!' + jsPath + '/**'
90+
],
91+
['copy:templates.frontend.base:template', browserSync.reload]);
92+
});
93+
94+
// Watch: Scripts
95+
gulp.task('watch:templates.frontend.base:scripts',
96+
function() {
97+
gulp.watch([
98+
jsPath + '/**/*.js',
99+
'!' + jsPath + '/**/*.min.js'
100+
],
101+
['scripts:templates.frontend.base', browserSync.reload]);
102+
});
103+
104+
// Watch: Styles
105+
gulp.task('watch:templates.frontend.base:less',
106+
function() {
107+
gulp.watch(
108+
[
109+
lessPath + '/**'
110+
],
111+
['less:templates.frontend.base', browserSync.reload]
112+
);
113+
});

0 commit comments

Comments
 (0)