-
Notifications
You must be signed in to change notification settings - Fork 3
/
gulpfile.js
96 lines (88 loc) · 2.73 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
92
93
94
95
96
let gulp = require('gulp'),
sass = require('gulp-sass'),
sourcemaps = require('gulp-sourcemaps'),
$ = require('gulp-load-plugins')(),
cleanCss = require('gulp-clean-css'),
rename = require('gulp-rename'),
postcss = require('gulp-postcss'),
autoprefixer = require('autoprefixer'),
postcssInlineSvg = require('postcss-inline-svg'),
browserSync = require('browser-sync').create()
pxtorem = require('postcss-pxtorem'),
postcssProcessors = [
postcssInlineSvg({
removeFill: true,
paths: ['./node_modules/bootstrap-icons/icons']
}),
pxtorem({
propList: ['font', 'font-size', 'line-height', 'letter-spacing', '*margin*', '*padding*'],
mediaQuery: true
})
];
const paths = {
scss: {
src: './scss/style.scss',
dest: './css',
watch: './scss/**/*.scss',
bootstrap: './node_modules/bootstrap/scss/bootstrap.scss',
},
js: {
bootstrap: './node_modules/bootstrap/dist/js/bootstrap.min.js',
jquery: './node_modules/jquery/dist/jquery.min.js',
popper: './node_modules/popper.js/dist/umd/popper.min.js',
poppermap: './node_modules/popper.js/dist/umd/popper.min.js.map',
barrio: '../../../../../../web/themes/contrib/bootstrap_barrio/js/barrio.js',
dest: './js'
}
}
// Compile sass into CSS & auto-inject into browsers
function styles () {
return gulp.src([paths.scss.bootstrap, paths.scss.src])
.pipe(sourcemaps.init())
.pipe(sass({
includePaths: [
'./node_modules/bootstrap/scss',
'../../../../../../web/themes/contrib/bootstrap_barrio/scss'
]
}).on('error', sass.logError))
.pipe($.postcss(postcssProcessors))
.pipe(postcss([autoprefixer({
browsers: [
'Chrome >= 35',
'Firefox >= 38',
'Edge >= 12',
'Explorer >= 10',
'iOS >= 8',
'Safari >= 8',
'Android 2.3',
'Android >= 4',
'Opera >= 12']
})]))
.pipe(sourcemaps.write())
.pipe(gulp.dest(paths.scss.dest))
.pipe(cleanCss())
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest(paths.scss.dest))
.pipe(browserSync.stream())
}
// Move the javascript files into our js folder
function js () {
return gulp.src([paths.js.bootstrap, paths.js.jquery, paths.js.popper, paths.js.poppermap, paths.js.barrio], {allowEmpty: true})
.pipe(gulp.dest(paths.js.dest))
.pipe(browserSync.stream())
}
// Static Server + watching scss/html files
function serve () {
browserSync.init({
proxy: {
target: 'https://islandora.traefik.me',
ws: true
}
})
gulp.watch([paths.scss.watch, paths.scss.bootstrap], styles).on('change', browserSync.reload)
}
const build = gulp.series(styles, gulp.parallel(js, serve))
exports.styles = styles
exports.js = js
exports.serve = serve
exports.default = build