-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
117 lines (103 loc) · 2.47 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
// Plugins.
var gulp = require('gulp');
var jshint = require('gulp-jshint');
var stylish = require('jshint-stylish');
var sass = require('gulp-sass');
var sourcemaps = require('gulp-sourcemaps');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var ngAnnotate = require('gulp-ng-annotate');
var rename = require('gulp-rename');
var compass = require('gulp-compass');
// We only want to process our own non-processed JavaScript files.
var jsPath = ['./scripts/*.js', '!./js/*.min.*'];
var sassPath = './sass/**/*.scss';
var phpPath = './**/*.php'; //could also be twig files
var buildDir = './js';
/**
* Run Javascript through JSHint.
*/
gulp.task('jshint', function(done) {
gulp.src(jsPath)
.pipe(jshint())
.pipe(jshint.reporter(stylish));
done();
});
/**
* Run Javascript through JSHint.
*/
gulp.task('uglify', function(done) {
gulp.src(jsPath)
.pipe(uglify())
.pipe(rename({
suffix: '-min'
}))
.pipe(gulp.dest('./scripts/min'))
done();
});
/**
* Process SCSS using libsass
*/
gulp.task('sass', function (done) {
gulp.src(sassPath)
.pipe(sass({
outputStyle: 'compressed',
includePaths: [
'./node_modules/compass-mixins/lib'
]
}).on('error', sass.logError))
.pipe(gulp.dest('./css'));
done();
});
/**
* Watch files for changes and run tasks.
*/
gulp.task('watch', function() {
gulp.watch(jsPath, gulp.series('jshint', 'uglify'));
gulp.watch(sassPath, gulp.series('sass'));
});
/**
* Watch javascript files for changes.
*/
gulp.task('js-watch', function() {
gulp.watch(jsPath, gulp.series('jshint'));
});
/**
* Build single app.js file.
*/
gulp.task('buildJs', function (done) {
gulp.src(jsPath)
.pipe(sourcemaps.init())
.pipe(uglify())
.pipe(sourcemaps.write('/maps'))
.pipe(rename({extname: ".min.js"}))
.pipe(gulp.dest(buildDir))
done();
});
/**
* Build single app.js file.
*/
gulp.task('assetsJs', function (done) {
gulp.src(jsAssets)
.pipe(concat('assets.js'))
.pipe(rename({extname: ".min.js"}))
.pipe(gulp.dest(buildDir))
done();
});
/**
* Use compass
*/
gulp.task('compass', function(done) {
gulp.src(sassPath)
.pipe(compass({
css: 'css',
sass: 'scss',
image: 'img'
}))
.pipe(minifycss())
.pipe(gulp.dest('html/css'));
done();
});
// Tasks to compile sass and watch js file.
gulp.task('default', gulp.parallel('sass', 'watch', 'uglify'));
gulp.task('build', gulp.parallel('buildJs', 'sass', 'uglify'));