-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
117 lines (100 loc) · 2.75 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
'use strict';
var config = {
paths: {
src: {
scripts: "app/src/**/*.js",
styles: "app/src/css/**/*.scss",
livereload: ["public/**/*"],
vendor: "app/vendor/**",
html: "app/src/templates/**/*.html"
},
dest: {
vendor: "public/vendor",
html: "public/templates"
}
}
};
var gulp = require('gulp'),
rjs = require("gulp-requirejs"),
rename = require('gulp-rename'),
autoprefixer = require('gulp-autoprefixer'),
sass = require('gulp-sass'),
jshint = require('gulp-jshint'),
stylish = require('jshint-stylish'),
livereload = require('gulp-livereload'),
newer = require('gulp-newer'),
livereloadServer = livereload(35729);
module.exports = gulp.task('watch', function () {
gulp.watch(config.paths.src.livereload)
.on('change', function (file) {
livereloadServer.changed(file.path);
});
// TODO: Find a proper way to ignore "possible EventEmitter memory leak detected", handled by maxListeners ATM
gulp.watch(config.paths.src.scripts, {
maxListeners: 999999
}, ['lint', 'rjs']);
gulp.watch(config.paths.src.html, {
maxListeners: 999999
}, ['html']);
gulp.watch(config.paths.src.styles, {
maxListeners: 999999
}, ['styles']);
});
function handleError(err) {
console.log(err.toString());
}
gulp.task('styles', function () {
return gulp.src("./app/src/css/index.scss")
.pipe(sass()
.on('error', handleError))
.pipe(autoprefixer('last 1 version'))
.pipe(rename('app.css'))
.pipe(gulp.dest('./public/css'));
});
gulp.task('stylesv2', function () {
return gulp.src("./app/src/css/style.scss")
.pipe(sass()
.on('error', handleError))
.pipe(autoprefixer('last 1 version'))
.pipe(rename('style.css'))
.pipe(gulp.dest('./public/css'));
});
gulp.task('html', function () {
return gulp.src(config.paths.src.html)
.pipe(gulp.dest(config.paths.dest.html));
});
module.exports = gulp.task('lint', function () {
return gulp.src(config.paths.src.scripts)
.pipe(jshint())
.pipe(jshint.reporter(stylish));
});
gulp.task('default', ["lint", "rjs", "styles", "html", "vendor"], function () {
gulp.run("watch");
});
gulp.task('vendor', function () {
return gulp.src(config.paths.src.vendor)
.pipe(newer(config.paths.dest.vendor))
.pipe(gulp.dest(config.paths.dest.vendor));
});
gulp.task('deploy', function () {
rjs({
baseUrl: 'app',
out: 'memapp.js',
"name": "src/base",
"deps": [],
"paths": {},
"shim": {}
})
.pipe(gulp.dest('./public/js')); // pipe it to the output DIR
});
gulp.task('rjs', function () {
rjs({
baseUrl: 'app',
out: 'app.js',
"name": "src/app",
"deps": [],
"paths": {},
"shim": {}
})
.pipe(gulp.dest('./public/js')); // pipe it to the output DIR
});