forked from AKVorrat/STI-UI
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Gulpfile.js
executable file
·112 lines (99 loc) · 3.55 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
const gulp = require('gulp'),
autoprefixer = require('gulp-autoprefixer'),
cssnano = require('gulp-cssnano'),
jshint = require('gulp-jshint'),
rename = require('gulp-rename'),
sass = require('gulp-sass'),
uglify = require('gulp-uglify'),
Promise = require('es6-promise');
const PATH = {
siteCSS: {
src : 'stylesheets/vendor/**/*.css',
dest: 'build/site/stylesheets/vendor'
},
questionnaireCSS: {
src : 'stylesheets/vendor/**/*.css',
dest: 'build/questionnaire/stylesheets/vendor'
},
siteSCSS : {
src : 'stylesheets/site/site.scss',
dest: 'build/site/stylesheets'
},
questionnaireSCSS : {
src : 'stylesheets/questionnaire/questionnaire.scss',
dest: 'build/questionnaire/stylesheets'
},
siteJS: {
src: ['scripts/shared/**/*.js', 'scripts/vendor/**/*.js', 'scripts/site/**/*.js'],
dest: 'build/site/scripts'
},
questionnaireJS: {
src: ['scripts/shared/**/*.js', 'scripts/vendor/**/*.js', 'scripts/questionnaire/**/*.js'],
dest: 'build/questionnaire/scripts'
}
};
gulp.task('siteSCSS', function () {
return gulp.src(PATH.siteSCSS.src)
.pipe(sass({errLogToConsole: true}))
.pipe(autoprefixer('last 4 version'))
.pipe(gulp.dest(PATH.siteSCSS.dest))
.pipe(cssnano())
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest(PATH.siteSCSS.dest));
});
gulp.task('questionnaireSCSS', function () {
return gulp.src(PATH.questionnaireSCSS.src)
.pipe(sass({errLogToConsole: true}))
.pipe(autoprefixer('last 4 version'))
.pipe(gulp.dest(PATH.questionnaireSCSS.dest))
.pipe(cssnano())
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest(PATH.questionnaireSCSS.dest));
});
gulp.task('siteJS',function(){
gulp.src(PATH.siteJS.src)
.pipe(gulp.dest(PATH.siteJS.dest))
.pipe(uglify())
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest(PATH.siteJS.dest));
});
gulp.task('questionnaireJS',function() {
gulp.src(PATH.questionnaireJS.src)
.pipe(gulp.dest(PATH.questionnaireJS.dest))
.pipe(uglify())
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest(PATH.questionnaireJS.dest));
});
gulp.task('siteCSS', function() {
gulp.src(PATH.siteCSS.src)
.pipe(gulp.dest(PATH.siteCSS.dest));
});
gulp.task('questionnaireCSS', function() {
gulp.src(PATH.questionnaireCSS.src)
.pipe(gulp.dest(PATH.questionnaireCSS.dest));
});
function copy_assets(directoryName) {
return gulp.src(directoryName + '/**/*')
.pipe(gulp.dest('build/site/' + directoryName))
.pipe(gulp.dest('build/questionnaire/' + directoryName));
}
gulp.task('images', function() {
return copy_assets('images');
});
gulp.task('fonts', function() {
return copy_assets('fonts');
});
gulp.task('icons', function() {
return copy_assets('icons');
});
gulp.task('default', ['icons', 'fonts', 'images', 'siteCSS', 'questionnaireCSS', 'siteSCSS', 'questionnaireSCSS', 'siteJS', 'questionnaireJS'], function () {
// gulp.watch("stylesheets/**/*.css", ['siteCSS', 'questionnaireCSS']);
gulp.watch("stylesheets/**/*.css", ['siteCSS']);
// gulp.watch("stylesheets/**/*.scss", ['siteSCSS', 'questionnaireSCSS']);
gulp.watch("stylesheets/**/*.scss", ['siteSCSS']);
gulp.watch("scripts/**/*.js", ['siteJS', 'questionnaireJS']);
gulp.watch("images/**/*", ['images']);
gulp.watch("fonts/**/*", ['fonts']);
gulp.watch("icons/**/*", ['icons']);
});
gulp.task('build', ['images', 'fonts', 'icons', 'siteCSS', 'questionnaireCSS', 'siteSCSS', 'questionnaireSCSS', 'siteJS', 'questionnaireJS']);