forked from SpiderBTT/NanoWallet-1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
151 lines (131 loc) · 4.29 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
var gulp = require('gulp');
var notify = require('gulp-notify');
var source = require('vinyl-source-stream');
var browserify = require('browserify');
var babelify = require('babelify');
var ngAnnotate = require('browserify-ngannotate');
var browserSync = require('browser-sync').create();
var rename = require('gulp-rename');
var templateCache = require('gulp-angular-templatecache');
var uglify = require('gulp-uglify');
var merge = require('merge-stream');
var glob = require('glob');
var sass = require('gulp-sass');
var autoprefixer = require('gulp-autoprefixer');
var NwBuilder = require('nw-builder');
var gutil = require('gulp-util');
// Where our files are located
var jsFiles = "src/app/**/*.js";
var viewFiles = "src/app/**/*.html";
var specFiles = "tests/specs/*.spec.js"
var specsArray = glob.sync(specFiles);
var interceptErrors = function(error) {
var args = Array.prototype.slice.call(arguments);
// Send error to notification center with gulp-notify
notify.onError({
title: 'Compile Error',
message: '<%= error.message %>'
}).apply(this, args);
// Keep gulp from hanging on this task
this.emit('end');
};
var autoprefixerOptions = {
browsers: ['last 6 versions']
};
// Task for app files
gulp.task('browserify', ['views'], function() {
return browserify('./src/app/app.js')
.transform(babelify, {presets: ["es2015"]})
.transform(ngAnnotate)
.bundle()
.on('error', interceptErrors)
//Pass desired output filename to vinyl-source-stream
.pipe(source('main.js'))
// Start piping stream to tasks!
.pipe(gulp.dest('./build/'));
});
// Task for test files
gulp.task('browserifyTests', function() {
return browserify(specsArray)
.transform(babelify, {presets: ["es2015"]})
.transform(ngAnnotate)
.bundle()
.on('error', interceptErrors)
//Pass desired output filename to vinyl-source-stream
.pipe(source('tests.js'))
// Start piping stream to tasks!
.pipe(gulp.dest('./build/tests/'));
});
// Just move files to build/
gulp.task('html', function() {
return gulp.src("src/start.html")
.on('error', interceptErrors)
.pipe(gulp.dest('./build/'));
});
gulp.task('tests', function() {
return gulp.src("tests/start.html")
.on('error', interceptErrors)
.pipe(gulp.dest('./build/tests'));
});
gulp.task('js', function() {
return gulp.src("src/vendors/**/*")
.on('error', interceptErrors)
.pipe(gulp.dest('./build/vendors'));
});
gulp.task('sass', function () {
return gulp.src('src/sass/nano.scss')
.pipe(sass().on('error', sass.logError))
.pipe(autoprefixer())
.pipe(gulp.dest('./build/css'));
});
gulp.task('css', function() {
return gulp.src('src/css/**/*')
.on('error', interceptErrors)
.pipe(gulp.dest('./build/css'))
})
gulp.task('images', function() {
return gulp.src("src/images/**/*")
.on('error', interceptErrors)
.pipe(gulp.dest('./build/images'));
});
gulp.task('package', function() {
return gulp.src("src/package.json")
.on('error', interceptErrors)
.pipe(gulp.dest('./build/'));
});
// Cache template
gulp.task('views', function() {
return gulp.src(viewFiles)
.pipe(templateCache({
standalone: true
}))
.on('error', interceptErrors)
.pipe(rename("app.templates.js"))
.pipe(gulp.dest('./src/app/config/'));
});
// Build App
gulp.task('app', function () {
var nw = new NwBuilder({
version: '0.25.4',
files: './build/**',
buildDir: './dist',
buildType: 'versioned',
winIco: './build/images/logomark.ico',
macIcns: './build/images/NanoWallet.icns',
platforms: ['win64', 'osx64', 'linux64']
});
// Log stuff you want
nw.on('log', function (msg) {
gutil.log('nw-builder', msg);
});
// Build returns a promise, return it so the task isn't called in parallel
return nw.build().catch(function (err) {
gutil.log('nw-builder', err);
});
});
// Run Tasks
gulp.task('default', ['html', 'js', 'sass', 'css', 'images', 'package', 'browserify', 'tests', 'browserifyTests'], function() {
});
// Build packaged apps for production
gulp.task('build-app', ['html', 'js', 'sass', 'css', 'images', 'package', 'app'], function() {
});