-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
133 lines (104 loc) · 2.88 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
var gulp = require('gulp');
var cleanCss = require('gulp-clean-css');
var browserSync = require('browser-sync').create();
var reload = browserSync.reload;
var uglify = require('gulp-uglify');
var gulpIf = require('gulp-if');
var del = require('del');
var concat = require('gulp-concat');
var jshint = require('gulp-jshint');
var inject = require('gulp-inject');
var sass = require('gulp-sass');
var paths = {
dev: {
home: 'www/',
all: 'www/**/*'
},
build: {
home: 'build/',
all: 'build/**/*'
},
scss: {
src: 'www/scss/**/*.scss',
dest: 'www/scss/comp'
},
css: {
src: 'www/css/**/*.css',
dest: 'build/css/'
},
js: {
src: 'www/js/**/*.js',
dest: 'build/js/'
}
};
gulp.task('default', ['serve'])
gulp.task('reset', function(){
del(paths.build.all);
});
gulp.task('scripts', function() {
return gulp.src(paths.js.src)
.pipe(jshint())
.pipe(jshint.reporter('default'))
.pipe(concat('main.min.js', {newLine: ';'}))
.pipe(gulp.dest(paths.js.dest))
.pipe(uglify({mangle: false}))
.pipe(gulp.dest(paths.js.dest))
});
gulp.task('styles', ['sass'], function() {
return gulp.src(paths.css.src)
.pipe(concat('styles.min.css'))
.pipe(gulp.dest(paths.css.dest))
.pipe(cleanCss({keepSpecialComments: 0}))
.pipe(gulp.dest(paths.css.dest))
});
gulp.task('sass', function(){
return gulp.src(paths.scss.src)
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest('www/css/'))
});
gulp.task('copy:lib', function(){
gulp.src('www/lib/**/*')
.pipe(gulp.dest(paths.build.home + 'lib'));
});
gulp.task('copy:assets', function(){
gulp.src('www/assets/**/*')
.pipe(gulp.dest(paths.build.home + 'assets'));
});
gulp.task('copy:html', function(){
gulp.src('www/templates/**/*')
.pipe(gulp.dest(paths.build.home + 'templates'));
gulp.src('www/index.html')
.pipe(gulp.dest(paths.build.home));
});
gulp.task('copy:bower', function(){
gulp.src('bower_components/**/*')
.pipe(gulp.dest(paths.build.home + 'bower_components'));
});
gulp.task('copy:all', ['copy:html', 'copy:assets', 'copy:bower']);
gulp.task('build', ['copy:all', 'scripts', 'styles']);
gulp.task('serve', function(){
browserSync.init({
server: {
baseDir: paths.build.home
}
});
// gulp.watch('www/lib/**/*', ['copy:lib']);
gulp.watch('www/**/*.html', ['copy:html']);
gulp.watch('www/assets/**/*', ['copy:assets']);
gulp.watch('www/js/*.js', ['scripts']);
gulp.watch('www/scss/*.scss', ['styles']);
gulp.watch('build/**/*').on("change", reload);
});
// gulp.task('inject:all', ['inject:css', 'inject:js'])
// gulp.task('inject:css', function(){
// var target = gulp.src('./build/index.html');
// var css = gulp.src('css/*.css');
// return target.pipe(inject(css))
// .pipe(gulp.dest(paths.build.home));
// });
// gulp.task('inject:js', function(){
// var target = gulp.src('index.html');
// var js = gulp.src('js/*.js');
// return target.pipe(inject(js))
// .pipe(gulp.dest(paths.build.home));
// });