-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
146 lines (129 loc) · 3.53 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
143
144
145
146
var gulp = require('gulp'),
babel = require('gulp-babel'),
uncss = require('gulp-uncss'),
cssnano = require('gulp-cssnano'),
csslint = require('gulp-csslint'),
sourcemaps = require('gulp-sourcemaps'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify'),
rename = require('gulp-rename'),
//clean = require('gulp-clean'),
//minifyhtml = require('gulp-minify-html'),
autoprefixer = require('gulp-autoprefixer'),
sass = require('gulp-sass'),
browserSync = require('browser-sync'),
browserReload = browserSync.reload;
var src = 'src';
var dist = 'dist';
/*
Clean up the build directory
gulp.task('clean', function () {
return gulp.src('assets/', {read: false})
.pipe(clean())
});
//Compress and combine vendors
gulp.task('vendor', function() {
return gulp.src('src/vendor/*.js')
.pipe(concat('vendor.js'))
.pipe(uglify())
.pipe(rename('vendor.min.js'))
.pipe(gulp.dest('assets/js/'))
});
Compress the HTML file
gulp.task('html', function () {
return gulp.src('src/HTML/*.html')
.pipe(minifyhtml())
.pipe(gulp.dest('./'))
});
*/
/*
Compress, compile and autoprefix SASS (SCSS) files
gulp.task('styles', function() {
return gulp.src('src/scss/*.scss')
.pipe(sass({outputStyle: 'compressed'}))
.pipe(autoprefixer({
browsers: ['> 1%', 'last 2 versions'],
}))
.pipe(gulp.dest('assets/css/'))
.pipe(browserSync.reload({stream:true}));
});
*/
//Compress and combine JS files
gulp.task('js', function() {
// return gulp.src(['js/*.js','js/atoms/*.js'])
return gulp.src('js/*.js')
.pipe(concat('main.js'))
.pipe(uglify())
.pipe(rename('main.min.js'))
.pipe(gulp.dest('js/min/'))
});
gulp.task('jsx', function() {
return gulp.src(src='jsx/*.jsx')
.pipe(babel())
.pipe(gulp.dest(dist))
});
gulp.task('concat', function() {
return gulp.src('dist/*.js')
.pipe(sourcemaps.init())
.pipe(babel())
.pipe(concat('screen.min.js'))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(dist));
});
gulp.task('csslint', function() {
gulp.src('./css/rdy.css')
.pipe(csslint({
'compatible-vendor-prefixes': false,
'box-sizing': false,
'important': false,
'known-properties': false
}))
.pipe(csslint.reporter());
});
gulp.task('workflow', function () {
gulp.src('sass/*.scss')
.pipe(sourcemaps.init())
.pipe(sass().on('error', sass.logError))
.pipe(autoprefixer({
browsers: ['last 2 versions'],
cascade: false
}))
// .pipe(uncss({
// html: ['index.html']
// }))
.pipe(cssnano())
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('css/'))
.pipe(browserSync.reload({stream:true}));
});
gulp.task('browser-sync', function() {
browserSync.init(null, {
server: {
baseDir: "./"
}
});
});
gulp.task('bs-reload', function () {
browserSync.reload();
});
gulp.task('default', ['workflow', 'js', 'jsx', 'concat', 'browser-sync', 'bs-reload'], function () {
gulp.start('workflow', 'csslint', 'js');
gulp.watch('sass/*.scss', ['workflow']);
gulp.watch('css/rdy.css', ['bs-reload']);
gulp.watch('js/min/main.min.js', ['bs-reload']);
gulp.watch('js/screen.js', ['jsx']);
gulp.watch('*.html', ['bs-reload']);
});
/*
Watch for changes
gulp.task('watch', function() {
gulp.watch('src/scss/*.scss',['styles']);
gulp.watch('src/vendor/*.js',['vendor']);
gulp.watch('src/js/*.js',['js']);
gulp.watch('src/HTML/*.html',['html']);
});
//Start the runAll and watch task at the beginning
gulp.task('default', ['runAll', 'watch']);
//run all tasks
gulp.task('runAll', ['vendor', 'js', 'html', 'styles']);
*/