forked from szerko/Respond2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
180 lines (142 loc) · 4.54 KB
/
Copy pathgulpfile.js
File metadata and controls
180 lines (142 loc) · 4.54 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
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
const gulp = require('gulp');
const zip = require('gulp-zip');
const Builder = require('systemjs-builder');
const ts = require('gulp-typescript');
const sourcemaps = require('gulp-sourcemaps');
const concat = require('gulp-concat');
const minify = require('gulp-minify');
// copy node modules (no longer needed with new build)
gulp.task('copy-nm', function() {
var src, dest;
src = 'node_modules/**/*';
dest = 'public/';
return gulp.src(src, {base:"."})
.pipe(gulp.dest(dest));
});
// create a zip for the release
gulp.task('create-zip', function() {
var bundlePaths = [
'app/**/*',
'bootstrap/**/*',
'database/**/*',
'design/**/*',
'public/app/**/*',
'public/i18n/**/*',
'public/themes/bootstrap/**/*',
'public/themes/foundation/**/*',
'public/themes/material/**/*',
'public/.htaccess',
'public/index.html',
'public/index.php',
'resources/emails/**/*',
'resources/views/**/*',
'storage/**/*',
'tests/**/*',
'typings/**/*',
'vendor/**/*',
'.env.example',
'artisan',
'LICENSE'
];
return gulp.src(bundlePaths, {base: './', follow: true})
.pipe(zip('release.zip'))
.pipe(gulp.dest('./dist'));
});
// copy dependencies
gulp.task('copy-libs', function() {
// copy folders
var libs = [
'node_modules/rxjs/**/*',
'node_modules/angular2-in-memory-web-api/**/*',
'node_modules/@angular/**/*',
'node_modules/ng2-translate/**/*'
];
return gulp.src(libs, {base: './node_modules/'})
.pipe(gulp.dest('public/dev/libs'));
});
// copy js
gulp.task('copy-files', function() {
return gulp.src([
'node_modules/angular2-jwt/angular2-jwt.js'
])
.pipe(gulp.dest('public/dev/libs/'));
});
// copy folders
gulp.task('copy-folders', function() {
// copy folders
var libs = [
'node_modules/hashedit/**/*'
];
return gulp.src(libs, {base: './node_modules/'})
.pipe(gulp.dest('public/app/libs'));
});
// copy js
gulp.task('copy-js', function() {
return gulp.src([
'node_modules/zone.js/dist/zone.js',
'node_modules/reflect-metadata/Reflect.js',
'node_modules/systemjs/dist/system.src.js',
'node_modules/moment/min/moment-with-locales.min.js',
'node_modules/dropzone/dist/min/dropzone.min.js'
])
.pipe(gulp.dest('public/app/libs/'));
});
// copy static files
gulp.task('copy-css', function() {
return gulp.src([
'node_modules/dropzone/dist/min/dropzone.min.css',
'node_modules/hashedit/dist/hashedit-min.css'
])
.pipe(gulp.dest('public/app/libs/'));
});
// copy static files
gulp.task('copy-static', function() {
var bundlePaths = [
'public/src/**/*.html',
'public/src/**/*.js',
'public/src/**/*.css',
'public/src/**/*.png'
];
return gulp.src(bundlePaths, {base: 'public/src'})
.pipe(gulp.dest('public/app'));
});
// #ref http://stackoverflow.com/questions/35280582/angular2-too-many-file-requests-on-load/37082199#37082199
var tsProject = ts.createProject('tsconfig.json');
gulp.task('ts', function() {
return gulp.src(['public/src/**/*.ts'])
.pipe(sourcemaps.init({
loadMaps: true
}))
.pipe(ts(tsProject))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('public/app'));
});
// bundle project
gulp.task('bundle', function() {
// optional constructor options
// sets the baseURL and loads the configuration file
var builder = new Builder('public', 'public/systemjs.config.js');
/*
the parameters of the below buildStatic() method are:
- your transcompiled application boot file (the one wich would contain the bootstrap(MyApp, [PROVIDERS]) function - in my case 'dist/app/boot.js'
- the output (file into which it would output the bundled code)
- options {}
*/
return builder
.buildStatic('app/main.js', 'public/app/bundle.js', { minify: true, sourceMaps: true})
.then(function() {
console.log('Build complete');
})
.catch(function(err) {
console.log('Build error');
console.log(err);
});
});
// copy
gulp.task('default', gulp.series(['copy-libs', 'copy-folders', 'copy-files', 'copy-js', 'copy-css', 'copy-static', 'ts', 'bundle']));
// dev-build
gulp.task('dev-build', gulp.series(['copy-static', 'ts']));
// build
gulp.task('build', gulp.series(['copy-static', 'ts', 'bundle']));
// create a zip file for the project in dist/release.zip
gulp.task('zip', gulp.series(['create-zip']));