-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
73 lines (63 loc) · 2.18 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
'use strict';
var gulp = require('gulp'),
sourcemaps = require('gulp-sourcemaps'),
postcss = require('gulp-postcss'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify'),
sprite = require('gulp-svg-sprite');
var paths = {
styles: ['static/styles/*.css', '!static/styles/build/**'],
scripts: ['node_modules/boomsvgloader/dist/js/boomsvgloader.js', 'static/scripts/*.js', '!static/scripts/build/**'],
sprites: ['static/images/icons/*.svg', '!static/images/icons/icon-sprite.svg']
};
var processors = [
require('postcss-import'),
require('postcss-nested'),
require('postcss-custom-properties'),
require('css-mqpacker')({sort: true}),
require('autoprefixer')('last 2 versions', '> 5% in US', 'Firefox ESR'),
require('cssnano')({autoprefixer: false, reduceIdents: false}) // Autoprefixer has just been run, don't do it again; reduceIdents is pretty unsafe.
];
gulp.task(function styles() {
return gulp.src('static/styles/app.css')
.pipe(sourcemaps.init())
.pipe(postcss(processors))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('static/styles/build/'));
});
gulp.task(function scripts() {
return gulp.src(paths.scripts)
.pipe(sourcemaps.init())
.pipe(concat('app.js'))
.pipe(uglify())
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('static/scripts/build/'));
});
gulp.task(function sprites() {
var options = {
mode: {
symbol: { // Create a «symbol» sprite.
dest: '.', // Don't create 'symbols/' directory.
prefix: '', // Don't prefix output title.
sprite: 'icon-sprite' // '.svg' will be appended if not included.
}
}
};
return gulp.src(paths.sprites)
.pipe(sprite(options))
.pipe(gulp.dest('static/images/icons'));
});
gulp.task(function watch() {
gulp.watch(paths.styles, gulp.series('styles'));
gulp.watch(paths.scripts, gulp.series('scripts'));
gulp.watch(paths.sprites, gulp.series('sprites'));
});
// Workflows
// $ gulp: Builds and watches for changes. The works.
gulp.task('default', gulp.parallel('styles', 'scripts', 'sprites', 'watch', function(done) {
done();
}));
// $ gulp build: Builds for deployments.
gulp.task('build', gulp.parallel('styles', 'scripts', 'sprites', function(done) {
done();
}));