-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
54 lines (48 loc) · 1.35 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
const { src, dest, parallel, watch, task} = require('gulp');
const browserSync = require('browser-sync').create();
const sass = require('gulp-sass');
const minifyCSS = require('gulp-csso');
const concat = require('gulp-concat');
const imagemin = require('gulp-imagemin');
function style() {
return src([
'node_modules/bootstrap/scss/bootstrap.scss',
'src/scss/*.scss'
])
.pipe(sass())
.pipe(minifyCSS())
.pipe(dest("src/css"))
.pipe(browserSync.stream());
}
function js() {
return src([
'node_modules/jquery/dist/jquery.min.js',
'node_modules/popper.js/dist/umd/popper.min.js',
'node_modules/bootstrap/dist/js/bootstrap.min.js'
], { sourcemaps: true })
.pipe(concat('app.min.js'))
.pipe(dest("src/js", { sourcemaps: true }))
.pipe(browserSync.stream());
}
function image() {
return src('src/img/**/*')
.pipe(imagemin())
.pipe(dest('src/imgmin'))
.pipe(browserSync.stream());
}
function watchFile() {
browserSync.init({
server: {
baseDir: './src'
},
browser: 'chrome'
});
watch('./src/scss/**/*.scss', style);
watch('./src/img/**/*', image);
watch('./src/**/*.html').on('change', browserSync.reload);
watch('./src/js/**/*.js').on('change', browserSync.reload);
}
exports.style = style;
exports.js = js;
exports.image = image;
exports.watchFile = parallel(js, style, image, watchFile);