-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
113 lines (95 loc) · 2.95 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
var gulp = require('gulp');
var sass = require('gulp-sass');
var sourcemaps = require('gulp-sourcemaps');
var connect = require('gulp-connect');
var minify = require('gulp-minify');
var concat = require('gulp-concat');
var gulpCopy = require('gulp-copy');
var rename = require('gulp-rename');
// -----------------------------------------------------------
// DEV LIB
// -----------------------------------------------------------
gulp.task('connect', function() {
connect.server({
root: './',
port: 8000,
livereload: true
});
});
// keeps gulp from crashing for scss errors
gulp.task('sass', function() {
return gulp.src('./sass/*.scss')
.pipe(sass({
errLogToConsole: true
}))
.pipe(sourcemaps.init())
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./css'));
});
gulp.task('livereload', function() {
gulp.src('./**/*')
.pipe(connect.reload());
});
gulp.task('watch', function() {
gulp.watch('./sass/**/*.scss', ['sass']);
gulp.watch('./**/*', ['livereload']);
});
gulp.task('watchonly', function() {
gulp.watch('./js/**/*',['build']);
});
// -----------------------------------------------------------
// BUILDING LIB
// -----------------------------------------------------------
gulp.task('dist-sass', function() {
gulp.src('./sass/styles.scss')
.pipe(sass({
errLogToConsole: true,
sourceMap: true
}))
.pipe(rename('liftJs.css'))
.pipe(sourcemaps.init())
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./dist'));
gulp.src('./sass/styles.scss')
.pipe(sass({
outputStyle: 'compressed',
errLogToConsole: true,
sourceComments: false,
sourceMap: false
}))
.pipe(rename('liftJs.min.css'))
.pipe(gulp.dest('./dist'));
});
gulp.task('dist-compress-main', function() {
gulp.src(['js/app.js', 'js/core/*.js'])
.pipe(concat('liftJs.js'))
.pipe(minify({
ext: {
min: '.min.js'
},
ignoreFiles: ['.min.js', '-min.js']
}))
.pipe(gulp.dest('dist'));
});
gulp.task('dist-compress-modules', function() {
gulp.src(['js/modules/**/*.js'])
.pipe(minify({
ext: {
min: '.min.js'
},
ignoreFiles: ['.min.js', '-min.js']
}))
.pipe(gulp.dest('dist/modules'));
gulp.src(['js/modules/**/*.html'])
.pipe(gulp.dest('dist/modules'));
});
gulp.task('dist-copy-libs', function() {
gulp.src(['js/libs/*.js'])
.pipe(gulp.dest('dist/libs'));
});
// -----------------------------------------------------------
// TASKS
// -----------------------------------------------------------
gulp.task('default', ['connect', 'sass', 'watch']);
gulp.task('build', ['dist-sass', 'dist-compress-main', 'dist-compress-modules', 'dist-copy-libs']);
gulp.task('livebuild', ['watchonly']);