This repository has been archived by the owner on Jun 26, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
73 lines (62 loc) · 1.81 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
// Gulp Modules
var gulp = require('gulp'),
consolidate = require('gulp-consolidate'),
uglify = require('gulp-uglify'),
concat = require('gulp-concat'),
path = require('path'),
watch = require('gulp-watch'),
plumber = require('gulp-plumber'),
rename = require('gulp-rename'),
sass = require('gulp-sass'),
sourcemaps = require('gulp-sourcemaps');
var environment = 'typo3';
var config;
switch (environment) {
case 'typo3':
config = [
sourcePath = 'Resources/Private/Src/',
destinationPath = 'Resources/Public/'
];
break;
}
var jsFilesApp = [
sourcePath + 'js/**/*.js'
];
var defaultTasks = [
'styles',
'scripts',
'watch'
];
gulp.task('default', defaultTasks);
gulp.task('watch', watchTask);
gulp.task('styles', stylesTask);
gulp.task('scripts', scriptsTask);
function watchTask() {
gulp.watch(sourcePath + 'scss/**/*.scss', ['styles']);
gulp.watch(jsFilesApp, ['scripts']);
}
function stylesTask() {
var compileStyles = function (baseName) {
gulp.src([sourcePath + 'scss/' + baseName + '.scss'])
.pipe(plumber())
.pipe(sourcemaps.init())
.pipe(sass({outputStyle: 'compressed'}))
.pipe(rename({suffix: '.min'}))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest(destinationPath + 'css'))
};
compileStyles('app');
}
function scriptsTask() {
var compileScripts = function (files, targetFile) {
gulp.src(files)
.pipe(plumber())
.pipe(sourcemaps.init())
.pipe(concat(targetFile + '.js'))
.pipe(uglify())
.pipe(rename({suffix: '.min'}))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest(destinationPath + 'js'));
};
compileScripts(jsFilesApp, 'app');
}