-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
98 lines (85 loc) · 2.68 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
'use strict';
var gulp = require('gulp');
var sass = require('gulp-sass');
var sourcemaps = require('gulp-sourcemaps');
var autoprefixer = require('gulp-autoprefixer');
var plumber = require('gulp-plumber');
var browserSync = require('browser-sync').create();
var cssmin = require('gulp-cssmin');
var uncss = require('gulp-uncss');
var stripCssComments = require('gulp-strip-css-comments');
var uglify = require('gulp-uglify');
var livereload = require('gulp-livereload')
var concat = require('gulp-concat');
var imagemin = require('gulp-imagemin');
var bourbon = require('bourbon').includePaths;
var neat = require('bourbon-neat').includePaths;
var svgSprite = require("gulp-svg-sprites");
var autoprefixerOptions = {
browsers: ['last 2 versions', '> 5%', 'Firefox ESR']
};
var sassOptions = {
errLogToConsole: true
}
//Uglifies javascript
gulp.task('jsprod', function() {
return gulp.src('js/source/*.js')
.pipe(uglify())
.pipe(gulp.dest('js/build'));
});
//Uglifies javascript
gulp.task('jsdev', function() {
return gulp.src('js/source/*.js')
//.pipe(uglify())
.pipe(gulp.dest('js/build'));
});
gulp.task('sprites', function () {
return gulp.src('assets/svg/*.svg')
.pipe(svgSprite({mode: "symbols"}))
.pipe(gulp.dest("assets"));
});
//Compiles sass
gulp.task('sassdev', function () {
gulp.src('./sass/**/*.scss')
.pipe(sass({
includePaths: ['sass'].concat(bourbon,neat)
}))
.pipe(sourcemaps.init())
.pipe(sass(sassOptions).on('error', sass.logError))
.pipe(stripCssComments({preserve: false}))
.pipe(cssmin())
.pipe(autoprefixer(autoprefixerOptions))
//.pipe(sourcemaps.write('.'))
.pipe(concat('style.css'))
.pipe(gulp.dest('./css'));
});
//Compiles sass
gulp.task('sassprod', function () {
gulp.src('./sass/**/*.scss')
.pipe(sass({
includePaths: ['sass'].concat(bourbon,neat)
}))
.pipe(sass(sassOptions).on('error', sass.logError))
.pipe(stripCssComments({preserve: false}))
.pipe(cssmin())
.pipe(autoprefixer(autoprefixerOptions))
.pipe(concat('style.min.css'))
.pipe(gulp.dest('./css'));
});
gulp.task('images', () =>
gulp.src('images/source/*')
.pipe(imagemin())
.pipe(gulp.dest('images/'))
);
//Type "gulp" on the command line to watch file changes
gulp.task('default', function(){
livereload.listen();
gulp.watch('./images/source/', ['images']);
gulp.watch('./sass/**/*.scss', ['sassdev']);
gulp.watch('./js/source/*.js', ['jsdev']);
gulp.watch(['./css/style.css', './**/*.twig', './js_min/*.js'], function (files){
livereload.changed(files)
});
});
//Type "gulp" on the command line to compile file changes
gulp.task('prod', [ 'sassprod', 'jsprod' ]);