-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGulpfile.js
More file actions
103 lines (87 loc) · 2.5 KB
/
Copy pathGulpfile.js
File metadata and controls
103 lines (87 loc) · 2.5 KB
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
'use strict';
var gulp = require('gulp'),
plumber = require('gulp-plumber'),
sass = require('gulp-sass'),
rename = require("gulp-rename"),
sourcemaps = require('gulp-sourcemaps'),
autoprefixer = require('gulp-autoprefixer'),
cssmin = require('gulp-cssmin'),
uglify = require('gulp-uglify'),
webserver = require('gulp-webserver');
/***********
*** SASS ***
************/
gulp.task('sass', function () {
console.log('COMPILING SASS');
return gulp.src('./sass/**/*.scss')
.pipe(plumber(function (error) {
console.log('sass error: compile plumber', error);
}))
.pipe(sourcemaps.init())
.pipe(sass().on('error', sass.logError))
.pipe(autoprefixer({
browsers: ['last 2 versions', 'Explorer >= 10', 'Android >= 4.1', 'Safari >= 7', 'iOS >= 7'],
cascade: false
}))
.pipe(sourcemaps.write())
.pipe(rename({ dirname: '' }))
.pipe(gulp.dest('./css'))
// minify
.pipe(cssmin())
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest('./css'));
});
/*****************
*** SASS WATCH ***
******************/
gulp.task('sass:watch', function () {
var watcher = gulp.watch('./sass/**/*.scss', ['sass']);
watcher.on('change', function (e) {
console.log('watcher.on.change type: ' + e.type + ' path: ' + e.path);
});
return watcher;
});
/*********
*** JS ***
**********/
gulp.task('js', function () {
console.log('MINIFYING JS');
return gulp.src('./js/main.js')
// minify
.pipe(uglify())
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest('./js'));
});
/***************
*** JS WATCH ***
****************/
gulp.task('js:watch', function () {
var watcher = gulp.watch('./js/main.js', ['js']);
watcher.on('change', function (e) {
console.log('watcher.on.change type: ' + e.type + ' path: ' + e.path);
});
return watcher;
});
/****************
*** WEBSERVER ***
*****************/
gulp.task('webserver', function () {
return gulp.src('./')
.pipe(webserver({
livereload: true,
directoryListing: false,
port: 8888,
open: true
}));
});
/***************************
*** PUBLISH TO WEBSERVER ***
****************************/
gulp.task('publish', function () {
gulp.src(['./**/*', '!./node_modules/**/*', '!./**/*.db'])
.pipe(gulp.dest('W:/cartella/'));
});
/************
*** START ***
*************/
gulp.task('start', ['sass', 'sass:watch']);