forked from biati-digital/glightbox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
75 lines (71 loc) · 2.31 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
const gulp = require('gulp');
const plumber = require('gulp-plumber');
const cache = require('gulp-cached');
const rename = require('gulp-rename');
const notify = require('gulp-notify');
const postcss = require('gulp-postcss');
const cssnano = require('cssnano');
const cssnext = require('postcss-cssnext');
const cssnesting = require('postcss-nesting');
const cssdiscard = require('postcss-discard-empty');
const cssmqpacker = require('css-mqpacker');
const cssimport = require('postcss-smart-import');
const cssprettify = require('postcss-prettify');
const cssnested = require('postcss-nested');
const cssfixes = require('postcss-fixes');
const cssmin = require('gulp-cssmin');
const csslost = require('lost');
const rucksack = require('rucksack-css');
const gulpbabel = require('gulp-babel');
const uglify = require('gulp-uglify');
const postCSSPlugins = [
cssimport(),
cssnested(),
csslost(),
cssnext({
browsers: ['last 2 version'],
features: {
calc: false
}
}),
rucksack(),
cssfixes({ preset: 'safe' }),
cssmqpacker({ sort: true }),
cssdiscard(),
cssprettify()
];
//CSS
gulp.task('postcss', function() {
return gulp.src('src/postcss/*.css')
.pipe(cache('postcss'))
.pipe(postcss(postCSSPlugins))
.pipe(gulp.dest('dist/css'))
.pipe(rename({ suffix: '.min' }))
.pipe(cssmin())
.pipe(gulp.dest('dist/css'))
.pipe(notify({ title: 'CSS Task', message: 'PostCSS compiled and minified' }));
});
// Scripts
gulp.task('scripts', function() {
return gulp.src(['./src/js/*.js', '!./**/*.min.js'])
.pipe(plumber())
.pipe(cache('scripts'))
.pipe(gulpbabel({
"plugins": ["transform-es2015-modules-umd"],
"presets": [["es2015", { "modules": false }]],
"moduleId": "GLightbox"
}))
.pipe(gulp.dest('dist/js'))
.pipe(rename({ suffix: '.min' }))
.pipe(uglify())
.pipe(gulp.dest('dist/js'))
.pipe(plumber.stop())
.pipe(notify({ title: 'Scripts Task', message: 'Scripts compiled and minified' }));
});
// Watch
gulp.task('watch', function(done) {
gulp.watch('src/postcss/*.css', gulp.series('postcss'));
gulp.watch('src/js/*.js', gulp.series('scripts'));
done();
});
gulp.task('default', gulp.series('watch'));