-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
91 lines (79 loc) · 2.56 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
let gulp = require('gulp'),
sass = require('gulp-sass'),
autoprefixer = require('gulp-autoprefixer'),
browserSync = require('browser-sync').create(),
uglify = require('gulp-uglify');
const paths = {
scss: {
src: './scss/style.scss',
dest: './css',
watch: './scss/**/*.scss'
},
js: {
bootstrap_src: './node_modules/bootstrap/dist/js/bootstrap.min.js',
bootstrap_dest: './js/bootstrap',
popper: './node_modules/@popperjs/core/dist/umd/popper.min.js',
popper_dest: './js/popper',
theme_src: './js/src/*.js',
theme_dest: './js'
},
twig: {
watch: './templates/**/*.twig'
},
};
// Compresss theme JS
function buildjs() {
return gulp
.src([paths.js.theme_src])
.pipe(gulp.dest(paths.js.theme_dest))
.pipe(browserSync.stream());
}
// Compile sass into CSS & auto-inject into browsers
function compile() {
var sassOptions = {
outputStyle: 'expanded',
indentType: 'space',
indentWidth: 2,
linefeed: 'lf'
};
return gulp
.src([paths.scss.src], { sourcemaps: true })
// .src([paths.scss.src])
.pipe(sass(sassOptions).on('error', sass.logError))
.pipe(autoprefixer())
// .pipe(gulp.dest(paths.scss.dest))
.pipe(gulp.dest([paths.scss.dest], { sourcemaps: true }))
.pipe(browserSync.stream());
}
// Move the Bootstrap JavaScript files into our js/bootstrap folder.
function move_bootstrap_js_files() {
return gulp
.src([paths.js.bootstrap_src])
.pipe(gulp.dest(paths.js.bootstrap_dest))
.pipe(browserSync.stream());
}
// Move the Popper JavaScript files into our js/popper folder.
function move_popper_js_files() {
return gulp
.src([paths.js.popper])
.pipe(gulp.dest(paths.js.popper_dest))
.pipe(browserSync.stream());
}
// Watching scss files.
function watch() {
browserSync.init({
proxy: "bs5.localhost:8888",
open: false
});
// gulp.watch([paths.js.theme_src], buildjs).on('change', browserSync.reload);
gulp.watch([paths.js.theme_src], buildjs);
gulp.watch([paths.scss.watch], compile);
gulp.watch([paths.twig.watch]).on('change', browserSync.reload);
}
const build = gulp.series(buildjs, compile, move_bootstrap_js_files, move_popper_js_files, gulp.parallel(watch));
exports.buildjs = buildjs;
exports.compile = compile;
exports.move_bootstrap_js_files = move_bootstrap_js_files;
exports.move_popper_js_files = move_popper_js_files;
exports.watch = watch;
exports.default = build;