forked from pwarocks/pwa.rocks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
69 lines (62 loc) · 1.41 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
const autoprefixer = require('autoprefixer');
const beml = require('gulp-beml');
const csso = require('postcss-csso');
const gulp = require('gulp');
const htmlmin = require('gulp-htmlmin');
const postcss = require('gulp-postcss');
const sass = require('gulp-sass');
const sync = require('browser-sync').create();
gulp.task('styles', () => {
return gulp.src('src/styles/screen.scss')
.pipe(sass().on('error', sass.logError))
.pipe(postcss([
autoprefixer,
csso
]))
.pipe(gulp.dest('dest/styles'))
.pipe(sync.stream());
});
gulp.task('html', () => {
return gulp.src('src/index.html')
.pipe(beml({
elemPrefix: '__',
modPrefix: '--' }))
.pipe(htmlmin({
removeComments: true,
collapseWhitespace: true
}))
.pipe(gulp.dest('dest'))
.pipe(sync.stream());
});
gulp.task('copy', () => {
return gulp.src('src/assets/**', { dot: true })
.pipe(gulp.dest('dest'))
.pipe(sync.stream({ once: true }));
});
gulp.task('server', () => {
sync.init({
notify: false,
server: {
baseDir: 'dest'
},
rewriteRules: [{
match: /location\.href = 'https:\/\/pwa\.rocks\/';/,
replace: '// Redirect removed during development.'
}]
});
});
gulp.task('watch', () => {
gulp.watch('src/styles/*.scss', ['styles']);
gulp.watch('src/index.html', ['html']);
gulp.watch('src/assets/**', ['copy']);
});
gulp.task('build', [
'styles',
'html',
'copy'
]);
gulp.task('default', [
'build',
'server',
'watch'
]);