-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
114 lines (96 loc) · 2.28 KB
/
gulpfile.js
File metadata and controls
114 lines (96 loc) · 2.28 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
111
112
113
114
(function() {
'use strict';
var gulp = require('gulp');
var runSequence = require('run-sequence');
var plumber = require('gulp-plumber');
var ENV = require('./get-env.js');
var paths = {
root: './',
less: './less/',
env: './components/env/env.json',
components: './components/',
};
/**
* Build
*/
gulp.task('generate-env-module', function() {
var ngConstant = require('gulp-ng-constant');
// This task builds the angular ENV constant
// Constants defined here extend the constants in env.json
var template =
"/**\n" +
" DO NOT EDIT\n" +
" Generated by gulp during build.\n" +
" Edit the generate-env-module task.\n" +
" */\n" +
"(function EnvironmentConstantIIFE() {\n" +
" 'use strict';\n\n" +
" angular.module('App.env', [])\n" +
" .constant('ENV', {\n" +
"<% constants.forEach(function(constant) { %>" +
" '<%- constant.name %>': <%= constant.value %>,\n" +
"<%});%>" +
" });\n" +
"}());";
return gulp.src(paths.env)
.pipe(ngConstant({
name: 'foo',
space: 4,
template: template,
constants: {
KINVEY_APP_KEY: ENV.KINVEY_APP_KEY,
KINVEY_APP_SECRET: ENV.KINVEY_APP_SECRET,
STRIPE_PUBLISHABLE_KEY: ENV.STRIPE_PUBLISHABLE_KEY
}
}))
.pipe(gulp.dest(paths.components + 'env'));
});
gulp.task('less', function() {
var autoprefixer = require('gulp-autoprefixer');
var less = require('gulp-less');
return gulp.src([
paths.less + 'app.less'
])
.pipe(plumber(function onError(err) {
console.log(err.message);
this.emit('end');
}
))
.pipe(less())
.pipe(autoprefixer())
.pipe(gulp.dest('.'));
});
/**
* Watch
*/
gulp.task('watch', function() {
gulp.watch([paths.root + '**/*.less'], ['less']);
});
/**
* Build
*/
gulp.task('build', function(cb) {
runSequence(
[
'generate-env-module',
'less',
],
cb
)
});
gulp.task('heroku:production', function(cb) {
runSequence(
[
'build'
],
cb
)
});
/**
* Default
*/
gulp.task('default', [
'build',
'watch',
]);
}());