This repository has been archived by the owner on Oct 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
86 lines (77 loc) · 2.52 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
const gulp = require('gulp'),
plumber = require('gulp-plumber'),
watch = require('gulp-watch'),
concat = require('gulp-concat'),
rename = require('gulp-rename'),
uglify = require('gulp-uglify'),
prefixer = require('gulp-autoprefixer'),
sourcemaps = require('gulp-sourcemaps'),
sass = require('gulp-sass'),
cssnano = require('gulp-cssnano'),
filter = require('gulp-filter'),
globToVinyl = require('glob-to-vinyl');
/**
* Fundament source and dist paths.
*/
const Fundament = {
js : {
src : 'src/js/*.js',
dist : 'dist/js'
},
sass : {
src : 'src/scss/build.scss',
watch : 'src/scss/**/*.scss',
dist : 'dist/css'
}
};
/**
* Gulp tasks.
*/
const tasks = {
js: function() {
gulp.src(Fundament.js.src)
.pipe(plumber())
.pipe(sourcemaps.init())
.pipe(concat('fundament.js'))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(Fundament.js.dist)) // compressed
.pipe(filter('**/*.js'))
.pipe(rename({suffix: '.min'}))
.pipe(uglify({preserveComments: 'license'}))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(Fundament.js.dist)); // minified
globToVinyl(Fundament.js.src, function(err, files) {
files.forEach(function(file) {
gulp.src(file.path)
.pipe(plumber())
.pipe(sourcemaps.init())
.pipe(uglify({preserveComments: 'license'}))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(Fundament.js.dist + '/components'));
});
});
},
sass: function() {
gulp.src(Fundament.sass.src)
.pipe(plumber())
.pipe(sourcemaps.init())
.pipe(sass())
.pipe(prefixer())
.pipe(concat('fundament.css'))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(Fundament.sass.dist)) // compressed
.pipe(filter('**/*.css'))
.pipe(rename({suffix: '.min'}))
.pipe(cssnano({zindex: false}))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(Fundament.sass.dist)); // minified
},
watch: function() {
gulp.watch(Fundament.js.src, ['js']);
gulp.watch(Fundament.sass.watch, ['sass']);
},
default: ['js', 'sass']
};
for (var task in tasks) {
gulp.task(task, tasks[task]);
}