-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.babel.js
52 lines (44 loc) · 1.33 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
import gulp from 'gulp';
import sass from 'gulp-sass';
import concat from 'gulp-concat';
import cleanCSS from 'gulp-clean-css';
import del from 'del';
import webpack from 'webpack-stream';
import webpackConfig from './webpack.config';
const paths = {
styles: {
src: 'src/styles/**/*.scss',
dest: `build/styles/`
},
scripts: {
src: 'src/scripts/**/*.js',
dest: `build/scripts/`
}
};
export const clean = (subDirectory = false) => del([`build/${(subDirectory ? '/' + subDirectory : '')}`]);
export function styles() {
return gulp.src(paths.styles.src)
.pipe(sass())
.pipe(cleanCSS())
.pipe(concat('gdprconsent.min.css'))
.pipe(gulp.dest(paths.styles.dest));
}
export function scripts() {
return gulp.src(paths.scripts.src, {sourcemaps: true})
.pipe(
webpack(webpackConfig)
.on('error', (err) => {
console.log(err.message);
this.emit('end'); // Recover from errors
})
)
.pipe(concat('gdprconsent.min.js'))
.pipe(gulp.dest(paths.scripts.dest));
}
function watchFiles() {
gulp.watch(paths.scripts.src, gulp.parallel(() => clean('scripts'), scripts));
gulp.watch(paths.styles.src, gulp.parallel(() => clean('styles'), styles));
}
export {watchFiles as watch};
export const build = gulp.series(clean, gulp.parallel(styles, scripts));
export default watchFiles;