-
Notifications
You must be signed in to change notification settings - Fork 8
/
gulpfile.js
142 lines (122 loc) · 3.62 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
var gulp = require('gulp');
var plumber = require('gulp-plumber');
var cleanCSS = require('gulp-clean-css');
var sass = require('gulp-dart-sass');
var clean = require('gulp-clean');
var browserSync = require('browser-sync').create();
var rename = require('gulp-rename');
var imgopt = require('gulp-smushit');
const purgecss = require('gulp-purgecss');
const htmlmin = require('gulp-htmlmin');
var htmlreplace = require('gulp-html-replace');
var reload = browserSync.reload;
// Configuration file to keep your code DRY
var cfg = require( './gulpconfig.json' );
var paths = cfg.paths;
sass.compiler = require('node-sass');
gulp.task('dist-assets', function (done) {
gulp.src('./src/js/**.*')
.pipe(gulp.dest('./dev/js'));
gulp.src('./src/img/**/**.*')
.pipe(gulp.dest('./dev/img'));
done();
});
gulp.task('prod-copy', function (done) {
gulp.src('./dev/**/**.*')
.pipe(gulp.dest('./public/'));
done();
});
gulp.task('minify-css', () => {
return gulp
.src('dev/css/*.css')
.pipe(cleanCSS({
compatibility: 'ie8'
}))
.pipe( rename( { suffix: '.min' } ) )
.pipe(gulp.dest('dev/css'))
.pipe(browserSync.stream());
});
// minifies HTML
gulp.task('minify-html', () => {
return gulp.src('public/*.html')
.pipe(htmlmin({ collapseWhitespace: false, removeComments: true }))
.pipe(gulp.dest('public'));
});
// Purging unused CSS
gulp.task('purgecss', () => {
return gulp.src('public/css/theme.min.css')
.pipe(purgecss({
content: ['public/**/*.html'],
safelist: ['collapsed', 'collapse', 'active', 'show', 'collapsing' ]
}))
.pipe(gulp.dest('public/css'))
})
gulp.task('clean-dist', function() {
return gulp.src('dist', {
read: false
})
.on('error', function(err) {
console.log(err.toString());
this.emit('end');
})
.pipe(clean());
});
gulp.task('clean', function() {
return gulp.src('dev/scss', {
read: false
})
.on('error', function(err) {
console.log(err.toString());
this.emit('end');
})
.pipe(clean());
});
gulp.task('browser-sync', function(done) {
browserSync.init({
server: {
baseDir: "./dev"
}
});
gulp.watch("dev/**/*.*").on('change', browserSync.reload);
});
// Compile sass to css
gulp.task('sass', function () {
return gulp.src('src/scss/theme.scss')
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest('dev/css'))
});
gulp.task('inject-min-css', function(done) {
gulp.src('./public/**/*.html')
.pipe(htmlreplace({
'css': 'css/theme.min.css'
}))
.pipe(gulp.dest('./public'));
done();
});
gulp.task('imgopt', function () {
return gulp.src('src/img/*.{jpg,png}')
.pipe(imgopt())
.pipe(gulp.dest('public/img'));
});
////////////////// All Bootstrap SASS Assets /////////////////////////
gulp.task( 'copy-assets', function( done ) {
////////////////// All Bootstrap 4 Assets /////////////////////////
// Copy all JS files
var stream = gulp
.src( paths.node + '/bootstrap/dist/js/**/*.*' )
.pipe( gulp.dest( paths.dev + '/js' ) );
// Copy all Bootstrap SCSS files
gulp
.src( paths.node + '/bootstrap/scss/**/*.scss' )
.pipe( gulp.dest( paths.dev + '/scss/assets/bootstrap' ) );
// Copy all Animate on Scroll css files
gulp
.src( paths.node + '/aos/dist/**/*.css' )
.pipe( gulp.dest( paths.dev + '/scss/assets/aos' ) );
// Copy all Animate on Scroll css files
gulp
.src( paths.node + '/aos/dist/**/*.js' )
.pipe( gulp.dest( paths.dev + '/js' ) );
////////////////// End Bootstrap 4 Assets /////////////////////////
done();
} );