-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
103 lines (96 loc) · 2.82 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
const gulp = require('gulp');
const autoprefixer = require('gulp-autoprefixer');
const csso = require('gulp-csso');
const rename = require("gulp-rename");
const concat = require("gulp-concat");
const sourcemaps = require("gulp-sourcemaps");
const plumber = require("gulp-plumber");
const wait = require("gulp-wait");
const del = require('del');
const sass = require("gulp-sass");
sass.compiler = require('node-sass');
const source = [
{
src: 'node_modules/@fortawesome/fontawesome-free/webfonts/**',
dest: 'public/vendor/webfonts/'
},
{
src: 'node_modules/bootstrap/scss/**',
dest: 'public/vendor/scss/'
}
];
const FileSource = [
{
src: [
'node_modules/bootstrap/dist/css/bootstrap.min.css',
'node_modules/@fortawesome/fontawesome-free/css/all.min.css'
],
concat: 'plugin.css',
dest: 'public/vendor/css/'
},
{
src: [
'node_modules/jquery/dist/jquery.min.js',
'node_modules/bootstrap/dist/js/bootstrap.min.js'
],
concat: 'plugin.js',
dest: 'public/vendor/js/'
}
];
gulp.task('del', async () => {
await del('public/vendor/**');
});
// COPY ALL FILES FROM SRC TO DIST
gulp.task('copy', async () => {
await new Promise(resolve => {
source.map(function (file) {
gulp.src(file.src)
.pipe(gulp.dest(file.dest))
.pipe(wait(1000))
.on('end', resolve);
});
});
await new Promise(resolve => {
FileSource.map(function (file) {
gulp.src(file.src)
.pipe(concat(file.concat))
.pipe(gulp.dest(file.dest))
.on('end', resolve);
});
});
});
// CONVERT DIST CSS TO MIN, loadMaps: true is doing load maps of scss files
gulp.task('css', () => {
wait(5000);
return gulp.src('public/css/style.css')
.pipe(wait(5000))
.pipe(sourcemaps.init({loadMaps: true}))
.pipe(autoprefixer({
cascade: false
}))
.pipe(csso())
.pipe(rename({
suffix: '.min'
}))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('public/css/'))
});
// CONVERT SASS TO CSS AND MOVE TO DIST
gulp.task('sass', async () => {
await new Promise(resolve => {
gulp.src('public/scss/main.scss')
.pipe(plumber())
.pipe(rename('style.css'))
.pipe(sourcemaps.init())
.pipe(sass.sync({outputStyle: 'expanded'}).on('error', sass.logError))
.pipe(autoprefixer({
cascade: false
}))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('public/css/'))
.on('end', resolve);
});
});
gulp.task('default', gulp.series(['del', 'copy', 'sass', 'css'], done => {
done();
}));