-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
executable file
·83 lines (70 loc) · 2.42 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
var gulp = require('gulp'),
sass = require('gulp-sass'),
csso = require('gulp-csso'),
uglify = require('gulp-uglify'),
concat = require('gulp-concat'),
plumber = require('gulp-plumber'),
del = require('del'),
sequence = require('run-sequence'),
jsPath = 'public/js',
jsDist = 'public/js/dist',
cssPath = 'public/css',
cssDist = 'public/css/dist',
libPath = 'public/lib',
nodeModulesPath = 'node_modules';
gulp.task('sass', function() {
gulp.src(cssPath + '/*.scss')
.pipe(plumber())
.pipe(sass({ errLogToConsole: true }))
.pipe(csso())
.pipe(gulp.dest(cssDist));
});
gulp.task('clean', function () {
return del(libPath + '/**/*', { force: true });
});
gulp.task('copy:libs', function (done) {
sequence('clean', 'copy:vendor', 'copy:rxjs', 'copy:angular', done);
});
gulp.task('copy:vendor', function() {
return gulp.src([
nodeModulesPath + '/core-js/client/**/*',
nodeModulesPath + '/zone.js/dist/zone.js',
nodeModulesPath + '/systemjs/dist/system-polyfills.js',
nodeModulesPath + '/systemjs/dist/system.src.js'
])
.pipe(gulp.dest(libPath));
});
gulp.task('copy:rxjs', function() {
return gulp.src([
nodeModulesPath + '/rxjs/**/*'
])
.pipe(gulp.dest(libPath + '/rxjs'));
});
gulp.task('copy:angular', function() {
// return gulp.src([
// 'node_modules/@angular/common/bundles/common.umd.js',
// 'node_modules/@angular/compiler/bundles/compiler.umd.js',
// 'node_modules/@angular/core/bundles/core.umd.js',
// 'node_modules/@angular/forms/bundles/forms.umd.js',
// 'node_modules/@angular/http/bundles/http.umd.js',
// 'node_modules/@angular/platform-browser/bundles/platform-browser.umd.js',
// 'node_modules/@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
// 'node_modules/@angular/router/bundles/router.umd.js',
// ])
return gulp.src([nodeModulesPath + '/@angular/**/*']).pipe(gulp.dest(libPath + '/@angular'));
});
gulp.task('compressScripts', function() {
gulp.src([
jsPath + '/**/*.js'
])
.pipe(concat('scripts.min.js'))
.pipe(uglify())
.pipe(gulp.dest(jsDist));
});
gulp.task('watch', function() {
gulp.watch(cssPath + '/*.scss', ['sass']);
gulp.watch([
jsPath + '/**/*.js', ['compressScripts']
]);
});
gulp.task('default', ['sass', 'compressScripts', 'watch']);