-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathGulpfile.js
More file actions
executable file
·110 lines (97 loc) · 2.67 KB
/
Gulpfile.js
File metadata and controls
executable file
·110 lines (97 loc) · 2.67 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
104
105
106
107
108
109
110
'use strict';
var gulp = require('gulp');
var nodemon = require('gulp-nodemon');
var bs = require('browser-sync').create();
var browserify = require('gulp-browserify');
var sass = require('gulp-sass');
var sourcemaps = require('gulp-sourcemaps');
var concat = require('gulp-concat');
var autoprefixer = require('gulp-autoprefixer');
var cssmin = require('gulp-minify-css');
var uglify = require('gulp-uglify');
var reload = bs.reload;
// define paths to app files
var paths = {
dist: 'client/dist',
scripts: {
src: 'client/js/**/*.js',
app: 'client/js/app.js',
libSrcs: ['client/lib/bower/angular/angular.js',
'client/lib/bower/angular-ui-router/release/angular-ui-router.js',
'client/lib/bower/jquery/dist/jquery.js'],
dist: 'client/dist/**/*.js'
},
html: ['client/**/*.html'],
scss: {
srcs: 'client/scss/**/*.scss',
main: 'client/scss/style.scss'
},
styles: {
libSrcs: ['client/lib/bower/normalize.css/normalize.css'],
dist: 'client/dist/**/*.css',
main: 'client/dist/style.css'
}
};
gulp.task('js', function() {
return gulp.src(paths.scripts.app)
.pipe(browserify({
debug: true
}))
.pipe(gulp.dest(paths.dist))
.pipe(bs.stream());
});
gulp.task('scss', function() {
return gulp.src(paths.scss.main)
.pipe(sourcemaps.init())
.pipe(sass())
.pipe(autoprefixer({
browsers: [
'last 2 versions',
'safari 5',
'ie 8',
'ie 9',
'android 4'
]
}))
.pipe(sourcemaps.write())
.pipe(gulp.dest(paths.dist))
.pipe(bs.stream());
});
gulp.task('libCSS', function() {
return gulp.src(paths.styles.libSrcs)
.pipe(concat('lib.css'))
.pipe(gulp.dest(paths.dist));
});
gulp.task('libJS', function() {
return gulp.src(paths.scripts.libSrcs)
.pipe(sourcemaps.init())
.pipe(concat('lib.js'))
.pipe(sourcemaps.write())
.pipe(gulp.dest(paths.dist));
});
gulp.task('minJS', ['libJS', 'js'], function() {
return gulp.src(paths.scripts.dist)
.pipe(uglify())
.pipe(gulp.dest(paths.dist));
});
gulp.task('minCSS', ['libCSS', 'scss'], function() {
return gulp.src(paths.styles.dist)
.pipe(cssmin())
.pipe(gulp.dest(paths.dist));
});
gulp.task('watch', function() {
gulp.watch(paths.html).on('change', reload);
gulp.watch(paths.scripts.src, ['js']);
gulp.watch(paths.scss.srcs,['scss']);
});
gulp.task('browser-sync', function() {
bs.init({
proxy: "localhost:8000",
open: false
});
});
gulp.task('serve', function() {
nodemon({ script: 'index.js', ignore: 'node_modules/**/*.js'});
});
gulp.task('prod', ['minJS', 'minCSS']);
gulp.task('default', ['libCSS', 'libJS', 'js', 'scss', 'watch', 'browser-sync', 'serve']);