forked from ampproject/amp.dev
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
81 lines (72 loc) · 2.04 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
var autoprefixer = require('gulp-autoprefixer');
var exec = require('child_process').exec;
var plumber = require('gulp-plumber');
var gulp = require('gulp');
var sass = require('gulp-sass');
var livereload = require('gulp-livereload');
var svgSprite = require('gulp-svg-sprite');
var Path = {
CSS_SOURCES: './assets/sass/**/*.scss',
CSS_OUT_DIR: './assets/css/'
};
gulp.task('import-docs', function (cb) {
exec('cd ./scripts && ./import_docs.js', function (err, stdout, stderr) {
if (err instanceof Error) {
cb(err);
}
//console.log(stdout);
cb();
});
});
gulp.task('optimize-images', function (cb) {
return gulp.src('./assets/img/symbols/*.svg')
.pipe(svgSprite({
mode: {
css: {
sprite: "../sprite.svg",
bust: false,
render: {
scss: {
template: "./assets/img/symbols/template.scss",
dest: "../../sass/_sprite_generated.scss"
}
}
}
}
}))
.pipe(gulp.dest('./assets/img/'));
});
gulp.task('update-blog-links', function (cb) {
exec('cd ./scripts && ./update_blog_links.js', function (err, stdout, stderr) {
if (err instanceof Error) {
cb(err);
}
//console.log(stdout);
cb();
});
});
gulp.task('update-platforms-page', ['import-docs'], function (cb) {
return exec('cd ./scripts && ./update_platforms_page.js', function (err, stdout, stderr) {
if (err instanceof Error) {
cb(err);
}
//console.log(stdout);
cb();
});
});
gulp.task('sass', function() {
return gulp.src(Path.CSS_SOURCES)
.pipe(plumber())
.pipe(sass({
outputStyle: 'compressed'
}).on('error', sass.logError))
.pipe(autoprefixer())
.pipe(gulp.dest(Path.CSS_OUT_DIR))
.pipe(livereload());
});
gulp.task('watch', function() {
livereload.listen();
gulp.watch([Path.CSS_SOURCES], ['sass']);
});
gulp.task('build', ['update-blog-links', 'import-docs', 'update-platforms-page', 'optimize-images', 'sass']);
gulp.task('default', ['update-platforms-page', 'sass', 'watch']);