forked from locomotivemtl/locomotive-scroll
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.js
75 lines (66 loc) · 1.84 KB
/
build.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
70
71
72
73
74
75
import gulp from 'gulp';
import postcss from 'gulp-postcss';
import rename from 'gulp-rename';
import cssnano from 'cssnano';
import merge from 'merge-stream';
import terser from 'gulp-terser-js';
import htmlmin from 'gulp-htmlmin';
import paths from '../mconfig.json';
function buildStyles() {
const stylesfiles = [
{
dest: paths.styles.dest
},
{
dest: paths.styles.docs.dest
}
];
const plugins = [
cssnano()
];
const stylesStreams = stylesfiles.map((file) => {
return gulp
.src([file.dest+'*.css', '!'+file.dest+'*.min.css'])
.pipe(rename(function(file) {
if (file.basename == paths.styles.main) {
file.basename += '.min';
}
}))
.pipe(postcss(plugins))
.pipe(gulp.dest(file.dest));
});
return merge(stylesStreams);
}
function buildScripts() {
const scriptsfiles = [
{
dest: paths.scripts.dest
},
{
dest: paths.scripts.docs.dest
}
];
const scriptsStreams = scriptsfiles.map((file) => {
return gulp
.src([file.dest+'*.js', '!'+file.dest+'*.esm.js', '!'+file.dest+'*.min.js'])
.pipe(rename(function(file) {
if (file.basename == paths.scripts.main) {
file.basename += '.min';
}
}))
.pipe(terser({
output: {
comments: false
}
}))
.pipe(gulp.dest(file.dest));
});
return merge(scriptsStreams);
}
function buildViews() {
return gulp
.src(paths.dest + '*.html')
.pipe(htmlmin('collapseWhitespace: true'))
.pipe(gulp.dest(paths.dest));
}
export { buildStyles, buildScripts, buildViews };