This repository has been archived by the owner on Aug 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
140 lines (124 loc) · 3.57 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
//load plugins
var gulp = require('gulp'),
compass = require('gulp-compass'),
autoprefixer = require('gulp-autoprefixer'),
// inlineCss = require('gulp-inline-css'),
minifycss = require('gulp-minify-css'),
uncss = require('gulp-uncss'),
// cmq = require('gulp-combine-media-queries'),
minifyhtml = require('gulp-minify-html'),
//jshint = require('gulp-jshint'),
uglify = require('gulp-uglify'),
imagemin = require('gulp-imagemin'),
// svgmin = require('gulp-svgmin'),
rename = require('gulp-rename'),
concat = require('gulp-concat'),
notify = require('gulp-notify'),
cache = require('gulp-cache'),
refresh = require('gulp-livereload'),
lr = require('tiny-lr'),
server = lr();
//styles
gulp.task('styles', function() {
return gulp.src(['src/sass/**/*.scss'])
.pipe(compass({
css: 'public_html/assets/css',
sass: 'src/sass',
image: 'public_html/assets/img'
}))
.pipe(autoprefixer('last 2 version', 'safari 5', 'ie 7', 'ie 8', 'ie 9', 'opera 12.1', 'ios 6', 'android 4'))
.pipe(gulp.dest('public_html/assets/css'))
// .pipe(rename({ suffix: '.min' }))
.pipe(minifycss())
.pipe(gulp.dest('public_html/assets/css'))
.pipe(refresh(server));
});
gulp.task('uncss', function() {
gulp.src('public_html/assets/css/master.css')
.pipe(uncss({
html: ['index.php']
}))
.pipe(gulp.dest('public_html/assets/css'));
});
// gulp.task('cmq', function () {
// gulp.src('src/sass/**/*.css')
// .pipe(cmq({
// log: true
// }))
// .pipe(gulp.dest('public_html/assets/css'));
// });
// gulp.task('inline-styles', function() {
// return gulp.src('src/html/*.html')
// .pipe(inlineCss({
// applyStyleTags: true,
// applyLinkTags: true,
// removeStyleTags: true,
// removeLinkTags: true
// }))
// .pipe(gulp.dest('public_html/'));;
// });
//scripts
gulp.task('scripts', function() {
return gulp.src('src/js/**/*.js')
//.pipe(jshint('.jshintrc'))
//.pipe(jshint.reporter('default'))
.pipe(concat('site.min.js'))
.pipe(gulp.dest('public_html/assets/js'))
// .pipe(rename({ suffix: '.min' }))
.pipe(uglify())
.pipe(gulp.dest('public_html/assets/js'))
.pipe(refresh(server));
});
//html
gulp.task('html', function() {
return gulp.src('public_html/index.html')
.pipe(refresh(server));
});
gulp.task('minifyhtml', function() {
gulp.src('src/html/index.html')
.pipe(minifyhtml())
.pipe(gulp.dest('./'))
});
//images
// gulp.task('images', function() {
// return gulp.src('public_html/assets/img/**/*')
// .pipe(cache(imagemin({ optimizationLevel: 3, progressive: true, interlaced: true })))
// .pipe(refresh(server))
// .pipe(gulp.dest('public_html/assets/img'));
// });
// gulp.task('svg', function() {
// return gulp.src('public_html/assets/img/**/*.svg')
// .pipe(svgmin())
// .pipe(gulp.dest('public_html/assets/img'));
// });
//default task
gulp.task('default', [], function() {
gulp.run('styles', 'scripts' ); //, 'images');
});
gulp.task('livereload', function(){
server.listen(35729, function(err){
if(err) return console.log(err);
});
});
//watch
gulp.task('live', function() {
gulp.run('livereload', 'styles');
//watch .scss files
gulp.watch('src/sass/**/*.scss', function(event) {
gulp.run('styles');
});
// watch .js files
gulp.watch('src/js/**/*.js', function(event) {
gulp.run('scripts');
});
//watch image files
// gulp.watch('public_html/assets/img/**/*', function(event) {
// console.log('File ' + event.path + ' was ' + event.type + ', running tasks...');
// gulp.run('images');
// });
//watch template files
gulp.watch('src/html/index.html', function(event) {
gulp.run('html');
gulp.run('minifyhtml');
});
});