Repository navigation
Expand file tree
/
Copy pathgulpfile.babel.js
More file actions
executable file
·89 lines (79 loc) · 2.08 KB
/
Copy pathgulpfile.babel.js
File metadata and controls
executable file
·89 lines (79 loc) · 2.08 KB
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
import gulp from 'gulp';
import sass from 'gulp-sass';
import htmlmin from 'gulp-htmlmin';
import watch from 'gulp-watch';
import minifyCss from 'gulp-minify-css';
import sourcemaps from 'gulp-sourcemaps';
import rename from 'gulp-rename';
const dirs = {
src: 'client',
dest: 'public'
}
const {src, dest} = dirs;
const paths = {
moveAssets: {
src: './assets/**/*',
dest: `./${dest}/assets`
},
sassToCSS: {
src: `./${src}/scss/main.scss`,
newName: 'style.css',
dest: `./${dest}/css`
},
unCSS: {
src: `./${dest}/css/style.css`,
html: [`./${src}/*.html`],
dest: `./${dest}/css`,
ignore: []
},
minifyCSS: {
src: `./${src}/css/style.css`,
newName: 'style.min.css',
dest: `./${dest}/css`
},
html: {
src: `./${src}/*.html`,
dest: `${dest}`
},
scss: {
src: `./${src}/scss/main.scss`,
dest: `./${dest}/css`,
watch: [
`./${src}/scss/**/*.scss`
]
}
};
gulp.task('moveAssets', () => {
return gulp.src(paths.moveAssets.src)
.pipe(gulp.dest(paths.moveAssets.dest));
});
gulp.task('moveHTML', () => {
return gulp.src(paths.html.src)
.pipe(gulp.dest(paths.html.dest));
});
gulp.task('minifyHTML', ['moveHTML'], () => {
return gulp.src(paths.html.src)
.pipe(htmlmin({collapseWhitespace: true}))
.pipe(gulp.dest(paths.html.dest));
});
gulp.task('sassToCSS', () => {
return gulp.src(paths.sassToCSS.src)
.pipe(sourcemaps.init())
.pipe(sass().on('error', sass.logError))
.pipe(sourcemaps.write())
.pipe(rename(paths.sassToCSS.newName))
.pipe(gulp.dest(paths.sassToCSS.dest));
});
gulp.task('minifyCSS', ['sassToCSS'], () => {
return gulp.src(paths.minifyCSS.src)
.pipe(minifyCss())
.pipe(rename(paths.minifyCSS.newName))
.pipe(gulp.dest(paths.minifyCSS.dest));
});
gulp.task('watch', () => {
gulp.watch(paths.moveAssets.src, ['moveAssets']);
gulp.watch(paths.html.src, ['moveHTML']);
gulp.watch(paths.scss.watch, ['sassToCSS']);
});
gulp.task('default', ['moveAssets', 'moveHTML', 'sassToCSS', 'watch']);
gulp.task('build', ['moveAssets', 'minifyHTML', 'minifyCSS']);