This repository has been archived by the owner on Sep 29, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
120 lines (105 loc) · 4.04 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
var gulp = require('gulp');
var htmlbars = require('gulp-htmlbars-compiler');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify-es').default;
var clean = require('gulp-clean');
var flatten = require('gulp-flatten');
// Hardcoded way to the ember-template-compilator as the versions needs to match and there is no node module in the repository
var compiler = require('./frontend/js/externals/ember-template-compiler-2.0.0');
// ====== Configuration =======
var paths = {
scriptsFrontend: [
'frontend/js/externals/jquery-2.1.4.js',
'frontend/js/externals/ember-2.0.0.js',
'frontend/js/externals/ember-shortcuts.js',
'frontend/js/externals/fingerprint.min.js',
'frontend/js/utils.js',
'frontend/js/app.js',
'frontend/js/routes.js',
'frontend/js/views.js',
'frontend/js/controllers.js',
'frontend/js/components.js',
'frontend/js/netteForms.js',
'frontend/js/overscroll.js',
'frontend/js/install.js'
],
scriptsBackend: [
'frontend/js/externals/jquery-2.1.4.js',
'frontend/js/nette.ajax.js',
'frontend/js/netteForms.js'
],
locales: [
'frontend/locales/**/*.js'
],
stylesFrontend: [
'frontend/css/animations.css',
'frontend/css/style.css',
'frontend/css/forms.css',
'frontend/css/responsive.css'
],
stylesBackend: [
'frontend/css/admin/**'
],
templates: [
'frontend/templates/**/*.hbs'
]
};
var destination = 'www/src/';
// ====== General tasks =======
gulp.task('clean', gulp.series(function () {
return gulp.src(destination, {read: false})
.pipe(clean());
}));
// ====== Stylesheet preparation =======
gulp.task('styles-backend', gulp.series(function() {
return gulp.src(paths.stylesBackend, { "base" : "./frontend/css/" })
.pipe(gulp.dest(destination));
}));
gulp.task('styles-frontend', gulp.series(function() {
return gulp.src(paths.stylesFrontend)
.pipe(concat('screen.css'))
.pipe(gulp.dest(destination));
}));
gulp.task('styles', gulp.series('styles-backend', 'styles-frontend', (done) => {done()}));
// ====== Javascript =======
gulp.task('scripts-backend', gulp.series(function() {
return gulp.src(paths.scriptsBackend, { "base" : "./frontend/js/" })
.pipe(flatten({dirname: ''}))
.pipe(gulp.dest(destination));
}));
gulp.task('scripts-frontend', gulp.series(function() {
return gulp.src(paths.scriptsFrontend.concat(paths.locales))
.pipe(concat('scripts.js'))
.pipe(gulp.dest(destination));
}));
gulp.task('scripts-frontend-mini', gulp.series(function() {
return gulp.src(paths.locales)
.pipe(concat('scripts-lo.js'))
//.pipe(uglify())
.pipe(gulp.dest(destination));
}));
gulp.task('scripts-full', gulp.series('scripts-backend', 'scripts-frontend', (done) => {done()}));
gulp.task('scripts-mini', gulp.series('scripts-backend', 'scripts-frontend-mini', (done) => { done() })); // For now backend scripts are not minified
// ====== Handlebars templates =======
gulp.task('templates', gulp.series(function() {
return gulp.src(paths.templates)
.pipe(htmlbars({
compiler: compiler // Required
//pathHandler: function(filePath, separator) { } // Optional way how to change naming of templates
}))
.pipe(concat('templates.js'))
.pipe(gulp.dest(destination));
}));
// ====== Other actions =======
gulp.task('watch', function() {
gulp.watch(paths.stylesFrontend, gulp.series('styles-frontend', (done) => { done() }));
gulp.watch(paths.stylesBackend, gulp.series('styles-backend', (done) => { done() }));
gulp.watch(paths.scriptsFrontend, gulp.series('scripts-frontend', (done) => { done() }));
gulp.watch(paths.scriptsBackend, gulp.series('scripts-backend', (done) => { done() }));
gulp.watch(paths.locales, gulp.series('scripts-frontend', (done) => { done() }));
gulp.watch(paths.templates, gulp.series('templates', (done) => { done() }));
});
gulp.task('default', gulp.series('styles', 'scripts-full', 'templates', (done) => { done(); }));
gulp.task('default-mini', gulp.series('styles', 'scripts-mini', 'templates', (done) => { done() }));
gulp.task('development', gulp.series('default', 'watch', (done) => { done() }));
gulp.task('production', gulp.series('default-mini', (done) => { done() }));