This repository has been archived by the owner on Mar 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
101 lines (91 loc) · 2.4 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
var gulp = require('gulp');
var plugins = require('gulp-load-plugins')({
pattern: '*'
});
var reload = plugins.browserSync.reload;
var processors = [plugins.autoprefixer];
// TASKS
// -- WATCH
// Add minjs task when JS would be ready
gulp.task('watch', ['browserSync', 'scss', 'normaljs', 'html'], function () {
gulp.watch('app/**/*.scss', ['scss']);
gulp.watch('app/**/*.js', ['normaljs']);
gulp.watch('app/**/*.html', ['html']);
});
// -- WATCH
// Add minjs task when JS would be ready
gulp.task('compile', ['scss', 'normaljs', 'html', /*'imagemin'*/], function () {
gulp.watch('app/**/*.scss', ['scss']);
gulp.watch('app/**/*.js', ['normaljs']);
gulp.watch('app/**/*.html', ['html']);
// gulp.watch('app/imgs/original/**/*.{jpg,png,gif,svg}', ['imagemin']);
});
// -- SCSS
gulp.task('scss', function () {
return gulp.src('app/scss/main.scss')
.pipe(plugins.plumber())
.pipe(plugins.sourcemaps.init())
.pipe(plugins.sass())
.pipe(plugins.postcss(processors))
.pipe(plugins.cleanCss({
compatibility: 'ie8'
}))
.pipe(plugins.sourcemaps.write('.'))
.pipe(gulp.dest('dist/css'))
.pipe(reload({ stream:true }));
/*.pipe(plugins.notify({
message: 'SCSS Compiled'
}))*/
});
// -- Minify JS
gulp.task('minjs', function () {
return gulp.src('app/**/*.js')
.pipe(plugins.minify({
ext: {
src: '-debug.js',
min: '.js'
},
exclude: ['tasks'],
ignoreFiles: ['.combo.js', '-min.js']
}))
.pipe(gulp.dest('dist/js'))
.pipe(reload({ stream:true }));
/*.pipe(plugins.notify({
message: 'JS Uglified'
}))*/
});
// -- Copy / Paste JS without Uglify
gulp.task('normaljs', function () {
return gulp.src('app/js/*.js')
.pipe(gulp.dest('dist/js'))
.pipe(reload({ stream:true }));
// .pipe(plugins.notify({
// message: 'JS Uploaded in dist file'
// }))
});
// -- IMG Minifier for PNG, JPG, GIF, SVG
gulp.task('imagemin', function () {
return gulp.src('app/imgs/**/*.{jpg,png,gif,svg}')
.pipe(plugins.imagemin())
.pipe(gulp.dest('./dist/imgs'));
// .pipe(plugins.notify({
// message: 'IMG Minified'
// }));
});
// -- Copy / Paste HTML
gulp.task('html', function () {
return gulp.src('app/**/*.html')
.pipe(plugins.htmlclean())
.pipe(gulp.dest('./dist'));
/*.pipe(plugins.notify({
message: 'HTML Minified'
}));*/
});
// -- Browser Sync Parameters
gulp.task('browserSync', function() {
plugins.browserSync.init({
server: {
baseDir: './dist'
},
});
});