-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
126 lines (112 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
var gulp = require('gulp'),
// Plugins:
autoprefixer = require('gulp-autoprefixer'),
del = require('del'),
eslint = require('gulp-eslint'),
extend = require('gulp-extend'),
minifyCss = require('gulp-minify-css'),
rev = require('gulp-rev'),
runWintersmith = require('run-wintersmith'),
sass = require('gulp-sass'),
sourcemaps = require('gulp-sourcemaps'),
svgSymbols = require('gulp-svg-symbols'),
uglify = require('gulp-uglify'),
usemin = require('gulp-usemin');
var assetsDir = 'app/contents/assets';
gulp.task('sass', function() {
return gulp
.src(assetsDir + '/scss/app.scss')
.pipe(sourcemaps.init())
.pipe(sass({
errLogToConsole: true,
sourceComments: 'map',
sourceMap: 'sass'
}))
.pipe(autoprefixer({
browsers: ['last 3 versions', '> 1% in GB'],
}))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(assetsDir + '/css'));
});
gulp.task('build:preclean', function() {
return del([
'tmp',
'build'
]);
});
gulp.task('build:postclean', function() {
return del([
'build.json',
'tmp'
]);
});
gulp.task('build:icons', function() {
return gulp.src(assetsDir + '/images/icons/*.svg')
.pipe(svgSymbols({
templates: ['default-svg']
}))
.pipe(gulp.dest(assetsDir + '/images/'));
});
gulp.task('build:copy', ['sass', 'build:icons', 'build:preclean'], function() {
return gulp
.src('app/**')
.pipe(gulp.dest('tmp'));
});
gulp.task('build:assets', ['build:copy'], function() {
return gulp
.src('tmp/templates/layouts/base.html')
.pipe(usemin({
css: [
minifyCss(),
rev()
],
js: [
uglify(),
rev()
],
headjs: [
uglify(),
rev()
],
assetsDir: 'tmp/contents/',
outputRelativePath: '../../contents/'
}))
.pipe(gulp.dest('tmp/templates/layouts'));
});
gulp.task('build:config', function() {
runWintersmith.settings.configFile = 'build.json';
return gulp
.src([
'config.json',
'config.build.json'
])
.pipe(extend('build.json', true, 2))
.pipe(gulp.dest(''));
});
gulp.task('build:html', ['build:assets', 'build:config'], function(cb) {
return runWintersmith.build(function() {
console.log('Wintersmith finished building...');
cb();
});
});
gulp.task('build', ['build:html']);
gulp.task('lint', function() {
return gulp
.src([
'gulpfile.js',
assetsDir + '/js/{,*/}*.js'
])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failOnError());
});
gulp.task('serve', function() {
runWintersmith.settings.hostname = '0.0.0.0';
runWintersmith.settings.port = 9000;
runWintersmith.preview();
});
gulp.task('watch', ['sass'], function() {
gulp.watch(assetsDir + '/scss/**', ['sass']);
gulp.watch(assetsDir + '/images/icons/*.svg', ['build:icons']);
});
gulp.task('default', ['serve', 'watch']);