-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
gulpfile.babel.js
53 lines (45 loc) · 1.37 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
import gulp from 'gulp';
import sass from 'gulp-sass';
import concat from 'gulp-concat';
import cleanCSS from 'gulp-clean-css';
import obfuscator from 'gulp-javascript-obfuscator';
import del from 'del';
import webpack from 'webpack-stream';
import webpackConfig from './webpack.config';
const paths = {
styles: {
src: 'assets/styles/**/*.scss',
dest: 'web/build/'
},
scripts: {
src: 'assets/scripts/**/*.js',
dest: 'web/build/'
}
};
export const clean = (subDirectory = false) => del([`build/${(subDirectory ? '/' + subDirectory : '')}`, `app/cache/twig/**/*`]);
export function styles() {
return gulp.src(paths.styles.src)
.pipe(sass())
.pipe(cleanCSS())
.pipe(concat('styles.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);
})
)
.pipe(obfuscator())
.pipe(concat('scripts.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;