-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
88 lines (72 loc) · 2.09 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
'use strict';
var gulp = require('gulp'),
less = require('gulp-less'),
path = require('path'),
rename = require('gulp-rename'),
sourcemaps = require('gulp-sourcemaps'),
autoprefixer = require('gulp-autoprefixer'),
cssmin = require('gulp-cssmin'),
browserSync = require('browser-sync').create(),
browserSyncReload = browserSync.reload,
browserify = require('browserify'),
debowerify = require('debowerify'),
uglify = require('gulp-uglify');
// LESS kompilace + SourceMaps
gulp.task('less', function () {
return gulp.src('./src/less/index.less')
.pipe(sourcemaps.init())
.pipe(less())
.pipe(rename('style.css'))
.pipe(autoprefixer({
browsers: ['last 3 versions', 'ios 6', 'ie 7', 'ie 8', 'ie 9'],
cascade: false
}))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./dist/css/'))
.pipe(browserSyncReload({stream: true}));
});
// CSS minifikace
gulp.task('cssmin', function () {
return gulp.src('./dist/css/style.css')
.pipe(cssmin())
.pipe(rename({
extname: ".min.css"
}))
.pipe(gulp.dest('./dist/css/'));
});
// JS browserify
// https://github.com/gulpjs/gulp/blob/master/docs/recipes/browserify-transforms.md
// TODO https://medium.com/@sogko/gulp-browserify-the-gulp-y-way-bb359b3f9623
// gulp.task('browserify', function () {
// var b = browserify({
// entries: './src/js/index.js',
// debug: true,
// transform: [debowerify]
// });
// return b.bundle()
// .pipe(source('./src/js/index.js'))
// .pipe(gulp.dest('./dist/js/'));
// });
// JS zmenseni
gulp.task('uglify', function () {
return gulp.src('./dist/js/script.js')
.pipe(uglify())
.pipe(rename('script.min.js'))
.pipe(gulp.dest('./dist/js/'))
});
// BrowserSync
gulp.task('browser-sync', function() {
browserSync.init({
server: {
baseDir: "./"
}
});
});
// Watch
gulp.task('watch', function() {
gulp.watch('./src/less/**/*.less', ['less']);
});
// Meta tasky
gulp.task('css', ['less', 'cssmin']);
gulp.task('js', ['uglify']);
gulp.task('default', ['css', 'browser-sync', 'watch']);