forked from nickpetersen/craft-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.babel.js
65 lines (59 loc) · 1.62 KB
/
gulpfile.babel.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
const { watch, dest, src, series } = require('gulp');
const browserSync = require('browser-sync').create();
const scss = require('gulp-sass');
const autoprefixer = require('gulp-autoprefixer');
const imagemin = require('gulp-imagemin');
const concat = require('gulp-concat');
const terser = require('gulp-terser');
const babel = require('gulp-babel');
const sourcemaps = require('gulp-sourcemaps');
const reload = browserSync.reload;
function css() {
return src('sass/**/*.scss')
.pipe(sourcemaps.init())
.pipe(
scss({
outputStyle: 'compressed',
includePaths: './node_modules/'
}).on('error', scss.logError)
)
.pipe(
autoprefixer({
browsers: 'last 2 versions'
})
)
.pipe(sourcemaps.write())
.pipe(dest('web/stylesheets/'))
.pipe(browserSync.stream());
}
function images() {
return src('images/*')
.pipe(imagemin())
.pipe(dest('web/assets/images/'));
}
function vendor() {
return src([
'node_modules/jquery/dist/jquery.js',
'node_modules/popper.js/dist/umd/popper.js',
'node_modules/bootstrap/dist/js/bootstrap.js'
])
.pipe(concat('vendors.js'))
.pipe(terser())
.pipe(dest('web/js'));
}
function js() {
return src('js/*.js')
.pipe(babel())
.pipe(terser())
.pipe(dest('web/js'));
}
exports.serve = series(css, images, vendor, js, () => {
browserSync.init({
proxy: 'https://craft-starter.test',
notify: false
});
watch('sass/**/**/*.scss', css);
watch('templates/**/**/**/*.twig').on('change', reload);
watch('js/*.js', js).on('change', reload);
});
exports.default = series(css, images, vendor, js);