-
Notifications
You must be signed in to change notification settings - Fork 31
/
gulpfile.js
100 lines (93 loc) · 2.35 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
var gulp = require('gulp'),
minifycss = require('gulp-minify-css'),
jshint = require('gulp-jshint'),
uglify = require('gulp-uglify'),
rename = require('gulp-rename'),
concat = require('gulp-concat-util'),
prefix = require('gulp-autoprefixer'),
groupMQ = require('gulp-group-css-media-queries'),
jade = require('gulp-jade'),
babel = require('gulp-babel');
var sass = require('gulp-sass');
sass.compiler = require('node-sass');
var paths = {
styles: 'styles/**/*.scss',
scripts: ['scripts/modules/**/*.js', 'scripts/init.js'],
templates: {
root: 'templates/index.jade',
},
watch: {
scripts: ['scripts/**/*.js', '!scripts/modules.js'],
styles: 'styles/**/*.scss',
templates: 'templates/**/*.jade',
},
root: './',
distribution: 'site/dist/',
};
gulp.task('styles', function () {
return gulp
.src(paths.styles)
.pipe(
sass().on('error', function (err) {
console.error('Error', err.message);
})
)
.pipe(
prefix({
browsers: ['last 2 versions', 'Safari >= 7'],
})
)
.pipe(groupMQ())
.pipe(gulp.dest(paths.distribution))
.pipe(minifycss())
.pipe(
rename(function (path) {
path.basename += '.min';
})
)
.pipe(gulp.dest(paths.distribution));
});
gulp.task('scripts', function () {
return gulp
.src(paths.scripts)
.pipe(jshint())
.pipe(jshint.reporter('default'))
.pipe(babel())
.pipe(
concat('app.js', {
process: function (src) {
return (src.trim() + '\n').replace(
/(^|\n)[ \t]*('use strict'|"use strict");?\s*/g,
'$1'
);
},
})
)
.pipe(concat.header("(function() {\n'use strict';\n"))
.pipe(concat.footer('\n})();'))
.pipe(gulp.dest(paths.distribution))
.pipe(
uglify({
mangle: false,
compress: false,
})
)
.pipe(rename('app.min.js'))
.pipe(gulp.dest(paths.distribution));
});
gulp.task('templates', function () {
return gulp
.src(paths.templates.root)
.pipe(
jade({
pretty: true,
})
)
.pipe(gulp.dest(paths.root));
});
gulp.task('default', ['styles', 'scripts', 'templates']);
gulp.task('dev', function () {
gulp.watch(paths.watch.styles, ['styles']);
gulp.watch(paths.watch.scripts, ['scripts']);
gulp.watch(paths.watch.templates, ['templates']);
});