-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
129 lines (99 loc) · 3.33 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
var prodPath = "app_prod";
var devPath = "app_dev";
var uglifyConfig = {
mangle: false
};
var jasmineConfig = {
integration: true,
abortOnFail: true,
vendor: [prodPath +'/scripts/**/*.js']
};
var gulp = require('gulp');
var jshint = require('gulp-jshint');
var babel = require('gulp-babel');
var concat = require('gulp-concat');
var sourcemaps = require('gulp-sourcemaps');
var jasmine = require('gulp-jasmine-phantom');
var serve = require('gulp-serve');
var useref = require('gulp-useref');
var compass = require('gulp-for-compass');
var uglify = require('gulp-uglify');
var clean = require('gulp-clean');
var rename = require('gulp-rename');
/** COMPILE SERVICES **/
gulp.task('compileServices', ['lintServices'], function () {
return gulp.src([devPath +'/services/**/+(Controllers|Models)/*.js', devPath +'/services/app.js'])
.pipe(sourcemaps.init())
.pipe(concat("app.js"))
.pipe(babel())
.pipe(sourcemaps.write("."))
.pipe(gulp.dest(prodPath +'/scripts'));
});
/** COMPILE VENDORS **/
gulp.task('compileVendors', function () {
return gulp.src(devPath +'/vendors/*.js')
.pipe(sourcemaps.init())
.pipe(concat("vendors.js"))
.pipe(sourcemaps.write("."))
.pipe(gulp.dest(prodPath +'/scripts'));
});
/** UGLIFY VENDORS **/
gulp.task('uglifyVendors', ['compileVendors'], function () {
return gulp.src(prodPath +'/scripts/vendors.js')
.pipe(uglify(uglifyConfig))
.pipe(gulp.dest(prodPath +'/scripts'));
});
/** COMPILE HTML **/
gulp.task('html', function () {
var assets = useref.assets();
return gulp.src(devPath +'/*.html')
.pipe(assets)
.pipe(assets.restore())
.pipe(useref())
.pipe(gulp.dest(prodPath));
});
/** COMPILE COMPASS **/
gulp.task('compass', function () {
return gulp.src(devPath +'/resources/scss/**/*.scss')
.pipe(compass({
sassDir: devPath +'/resources/scss',
cssDir: prodPath +'/styles',
outputStyle: 'compressed'
}));
});
/** CLEAN RESOURCES **/
gulp.task('cleanResources', function () {
return gulp.src(prodPath +'/resources')
.pipe(clean());
});
/** MOVE RESOURCES **/
gulp.task('moveResources', ['cleanResources'], function () {
return gulp.src(devPath +'/resources/+(fonts|images|videos)/**/*')
.pipe(gulp.dest(prodPath +'/resources'));
});
/** CLEAN VIEWS **/
gulp.task('cleanViews', function () {
return gulp.src(prodPath +'/templates')
.pipe(clean());
});
/** MOVE VIEWS **/
gulp.task('moveViews', ['cleanViews'], function () {
return gulp.src(devPath +'/services/**/Views/*.hbs')
.pipe(rename({dirname: ''}))
.pipe(gulp.dest(prodPath +'/templates'));
});
/** VERIFY JAVASCRIPT **/
gulp.task('lintServices', function() {
return gulp.src(devPath +'/services/**/+(Controllers|Models)/*.js')
.pipe(jshint({esnext: true}))
.pipe(jshint.reporter('jshint-stylish'));
});
/** RUN TESTS **/
gulp.task('tests', ['compileServices'], function () {
return gulp.src('tests/**/*.js')
.pipe(jasmine(jasmineConfig));
});
/** TASK PROD **/
gulp.task('prod', ['compileServices', 'uglifyVendors', 'html', 'compass', 'moveViews', 'moveResources']);
/** TASK SERVE **/
gulp.task('serve', ['prod'], serve('app_prod'));