This repository has been archived by the owner on Oct 31, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
gulpfile.js
163 lines (146 loc) · 4.39 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
/*jshint node: true*/
var gulp = require('gulp'),
less = require('gulp-less'),
env = require('node-env-file'), //create the env
envfile = require('envfile'), //parse the env
jshint = require('gulp-jshint'),
htmlify = require('gulp-angular-htmlify'),
open = require('gulp-open'),
nodemon = require('gulp-nodemon'),
autoprefixer = require('gulp-autoprefixer'),
notify = require('gulp-notify'),
concat = require('gulp-concat'),
templateCache = require('gulp-angular-templatecache'),
sourcemaps = require('gulp-sourcemaps'),
watch = require('gulp-watch'),
uglify = require('gulp-uglify'),
gulpif = require('gulp-if'),
livereload = require('gulp-livereload'),
ngAnnotate = require('gulp-ng-annotate'),
plumber = require('gulp-plumber'),
babel = require('gulp-babel'),
iife = require('gulp-iife');
awspublish = require('gulp-awspublish');
gulp.task('env', function () {
env(__dirname + '/.env', {overwrite: true});
});
gulp.task('templates', function () {
gulp.src('./app/**/*.html')
.pipe(htmlify())
.pipe(templateCache({
standalone: true
}))
.pipe(gulp.dest('./build/js'))
.pipe(livereload());
});
gulp.task('scripts', function () {
var baseDir = __dirname + '/app',
outputDir = __dirname + '/build/js',
outputFilename = 'app.js',
env = envfile.parseFileSync('.env');
gulp.src([
baseDir + "/*module.js",
baseDir + "/**/*module.js",
baseDir + "/**/*.js"
])
.pipe(iife())
.pipe(jshint())
.pipe(jshint.reporter('default'))
.pipe(sourcemaps.init())
.pipe(babel({
presets: ['es2015']
}))
.pipe(concat(outputFilename))
.pipe(ngAnnotate())
.pipe(gulpif(env.PRODUCTION === 'true', uglify()))
.pipe(sourcemaps.write())
.pipe(gulp.dest(outputDir))
.pipe(notify({
title: 'ngAnnotate',
subtitle: 'Angular Compiled!',
message: ' '
}));
});
gulp.task('js-deps', function () {
gulp.src([
'./node_modules/angular/angular.min.js',
'./node_modules/angular-ui-router/release/angular-ui-router.min.js'
//Add your scripts here
])
.pipe(concat('deps.js'))
.pipe(gulp.dest('./build/js'));
});
gulp.task('less', function () {
gulp.src([
'./less/app.less' //main entry point for styles. All other sheets should be included here.
])
.pipe(plumber())
.pipe(less())
.pipe(autoprefixer())
.pipe(gulp.dest('./build/css'));
});
gulp.task('copy-img', function () {
gulp.src(['./images/*.*', './images/**/*.*'])
.pipe(gulp.dest('./build/images'));
});
gulp.task('css-deps', function () {
gulp.src([
'./node_modules/bootstrap/dist/css/bootstrap.min.css',
'./node_modules/font-awesome/css/font-awesome.min.css'
//Add your third party styles here
])
.pipe(concat('deps.css'))
.pipe(gulp.dest('./build/css'));
gulp.src('./node_modules/font-awesome/fonts/*.*')
.pipe(gulp.dest('./build/fonts'));
gulp.src('./fonts/**/*.*')
.pipe(gulp.dest('./build/css'));
});
gulp.task('favicon', function () {
gulp.src('./app/favicon.ico')
.pipe(gulp.dest('./build'));
});
gulp.task('watch', function () {
gulp.watch([
'./build/**/*.js',
'./build/**/*.css',
'./build/**/*.html'
], function (event) {
return gulp.src(event.path)
.pipe(livereload());
});
gulp.watch(['.env'], ['env']);
gulp.watch(['app/*.js', 'app/**/*.js'], ['scripts']);
gulp.watch('less/**/*.less', ['less']);
gulp.watch('app/**/*.html', ['templates']);
gulp.watch('images/**/*.*', ['copy-img']);
});
gulp.task('serve', ['env', 'scripts', 'js-deps', 'css-deps', 'templates', 'less', 'copy-img', 'favicon', 'watch'], function () {
nodemon({
script: 'app.js',
ext: 'js html ejs',
ignore: ['node_modules']
});
livereload.listen();
});
gulp.task('publish', function() {
// user must manually create ~/.aws/credentials file, AWS SDK will automatically check for it
var publisher = awspublish.create({
region: '', //example: 'us-west-2'
params: {
Bucket: '' //example: 'epicapp.s3sandbox.com'
}
});
return gulp.src('./build/**/*.*')
.pipe(publisher.publish())
.pipe(publisher.cache())
// warning sync will delete files in your bucket that are not in your local folder.
.pipe(publisher.sync())
// print upload updates to console
.pipe(awspublish.reporter());
states: ['create', 'update', 'delete']
});
/**
* General Build
*/
gulp.task('default', ['serve']);