Commit 39f02c6899c2356c973579a60168672ece09d54a
1 parent
78630a96dc
Exists in
master
uglify
Showing
1 changed file
with
1 additions
and
0 deletions
Show diff stats
gulpfile.js
1 | const templateCache = require('gulp-angular-templatecache'); | 1 | const templateCache = require('gulp-angular-templatecache'); |
2 | const clean = require('gulp-clean'); | 2 | const clean = require('gulp-clean'); |
3 | const concat = require('gulp-concat'); | 3 | const concat = require('gulp-concat'); |
4 | const htmlmin = require('gulp-htmlmin'); | 4 | const htmlmin = require('gulp-htmlmin'); |
5 | const rename = require('gulp-rename'); | 5 | const rename = require('gulp-rename'); |
6 | const uglify = require('gulp-uglify'); | 6 | const uglify = require('gulp-uglify'); |
7 | const gulp = require('gulp'); | 7 | const gulp = require('gulp'); |
8 | const pump = require('pump'); | 8 | const pump = require('pump'); |
9 | const jshint = require('gulp-jshint'); | 9 | const jshint = require('gulp-jshint'); |
10 | const replace = require('gulp-replace'); | 10 | const replace = require('gulp-replace'); |
11 | const connect = require('gulp-connect'); | 11 | const connect = require('gulp-connect'); |
12 | const header = require('gulp-header'); | 12 | const header = require('gulp-header'); |
13 | const footer = require('gulp-footer'); | 13 | const footer = require('gulp-footer'); |
14 | const gulpSequence = require('gulp-sequence'); | 14 | const gulpSequence = require('gulp-sequence'); |
15 | 15 | ||
16 | var paths = { | 16 | var paths = { |
17 | srcJS: 'src/js/*.js', | 17 | srcJS: 'src/js/*.js', |
18 | srcViews: 'src/views/*.html', | 18 | srcViews: 'src/views/*.html', |
19 | specs: 'spec/*.js', | 19 | specs: 'spec/*.js', |
20 | tmp: 'tmp', | 20 | tmp: 'tmp', |
21 | dist: 'dist/' | 21 | dist: 'dist/' |
22 | }; | 22 | }; |
23 | 23 | ||
24 | gulp.task('uglify', gulpSequence('clean', ['templates', 'uglify-spec'], 'uglify-app')); | 24 | gulp.task('uglify', gulpSequence('clean', ['templates', 'uglify-spec'], 'uglify-app')); |
25 | 25 | ||
26 | gulp.task('templates', ['clean'], function() { | 26 | gulp.task('templates', ['clean'], function() { |
27 | return pump( | 27 | return pump( |
28 | [ | 28 | [ |
29 | gulp.src(paths.srcViews), | 29 | gulp.src(paths.srcViews), |
30 | htmlmin(), | 30 | htmlmin(), |
31 | templateCache('views.js', { | 31 | templateCache('views.js', { |
32 | module: 'focaCrearRemito', | 32 | module: 'focaCrearRemito', |
33 | root: '' | 33 | root: '' |
34 | }), | 34 | }), |
35 | gulp.dest(paths.tmp) | 35 | gulp.dest(paths.tmp) |
36 | ] | 36 | ] |
37 | ); | 37 | ); |
38 | }); | 38 | }); |
39 | 39 | ||
40 | gulp.task('uglify-app', function() { | 40 | gulp.task('uglify-app', function() { |
41 | return pump( | 41 | return pump( |
42 | [ | 42 | [ |
43 | gulp.src([ | 43 | gulp.src([ |
44 | paths.srcJS, | 44 | paths.srcJS, |
45 | 'tmp/views.js' | 45 | 'tmp/views.js' |
46 | ]), | 46 | ]), |
47 | concat('foca-crear-remito.js'), | 47 | concat('foca-crear-remito.js'), |
48 | replace('src/views/', ''), | 48 | replace('src/views/', ''), |
49 | gulp.dest(paths.tmp), | 49 | gulp.dest(paths.tmp), |
50 | rename('foca-crear-remito.min.js'), | 50 | rename('foca-crear-remito.min.js'), |
51 | uglify(), | ||
51 | gulp.dest(paths.dist) | 52 | gulp.dest(paths.dist) |
52 | ] | 53 | ] |
53 | ); | 54 | ); |
54 | }); | 55 | }); |
55 | 56 | ||
56 | gulp.task('uglify-spec', function() { | 57 | gulp.task('uglify-spec', function() { |
57 | return pump( | 58 | return pump( |
58 | [ | 59 | [ |
59 | gulp.src(paths.specs), | 60 | gulp.src(paths.specs), |
60 | concat('foca-crear-remito.spec.js'), | 61 | concat('foca-crear-remito.spec.js'), |
61 | replace('src/views/', ''), | 62 | replace('src/views/', ''), |
62 | header("describe('Módulo foca-crear-remito', function() { \n"), | 63 | header("describe('Módulo foca-crear-remito', function() { \n"), |
63 | footer("});"), | 64 | footer("});"), |
64 | gulp.dest(paths.dist) | 65 | gulp.dest(paths.dist) |
65 | ] | 66 | ] |
66 | ); | 67 | ); |
67 | }); | 68 | }); |
68 | 69 | ||
69 | gulp.task('clean', function() { | 70 | gulp.task('clean', function() { |
70 | return gulp.src(['tmp', 'dist'], {read: false}) | 71 | return gulp.src(['tmp', 'dist'], {read: false}) |
71 | .pipe(clean()); | 72 | .pipe(clean()); |
72 | }); | 73 | }); |
73 | 74 | ||
74 | gulp.task('pre-commit', function() { | 75 | gulp.task('pre-commit', function() { |
75 | return pump( | 76 | return pump( |
76 | [ | 77 | [ |
77 | gulp.src([paths.srcJS, paths.specs]), | 78 | gulp.src([paths.srcJS, paths.specs]), |
78 | jshint('.jshintrc'), | 79 | jshint('.jshintrc'), |
79 | jshint.reporter('default'), | 80 | jshint.reporter('default'), |
80 | jshint.reporter('fail') | 81 | jshint.reporter('fail') |
81 | ] | 82 | ] |
82 | ); | 83 | ); |
83 | 84 | ||
84 | gulp.start('uglify'); | 85 | gulp.start('uglify'); |
85 | }); | 86 | }); |
86 | 87 | ||
87 | gulp.task('webserver', function() { | 88 | gulp.task('webserver', function() { |
88 | pump [ | 89 | pump [ |
89 | connect.server({port: 3300, host: '0.0.0.0'}) | 90 | connect.server({port: 3300, host: '0.0.0.0'}) |
90 | ] | 91 | ] |
91 | }); | 92 | }); |
92 | 93 | ||
93 | gulp.task('clean-post-install', function() { | 94 | gulp.task('clean-post-install', function() { |
94 | return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js', | 95 | return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js', |
95 | 'index.html'], {read: false}) | 96 | 'index.html'], {read: false}) |
96 | .pipe(clean()); | 97 | .pipe(clean()); |
97 | }); | 98 | }); |
98 | 99 | ||
99 | gulp.task('default', ['webserver']); | 100 | gulp.task('default', ['webserver']); |
100 | 101 | ||
101 | gulp.task('watch', function() { | 102 | gulp.task('watch', function() { |
102 | gulp.watch([paths.srcJS, paths.srcViews], ['uglify']); | 103 | gulp.watch([paths.srcJS, paths.srcViews], ['uglify']); |
103 | }); | 104 | }); |
104 | 105 | ||
105 | gulp.task('copy', ['uglify'], function() { | 106 | gulp.task('copy', ['uglify'], function() { |
106 | return gulp.src('dist/*.js') | 107 | return gulp.src('dist/*.js') |
107 | .pipe(gulp.dest('../../wrapper-demo/node_modules/foca-crear-remito/dist/')); | 108 | .pipe(gulp.dest('../../wrapper-demo/node_modules/foca-crear-remito/dist/')); |
108 | }); | 109 | }); |
109 | 110 | ||
110 | gulp.task('watchAndCopy', function() { | 111 | gulp.task('watchAndCopy', function() { |
111 | return gulp.watch([paths.srcJS, paths.srcViews], ['copy']); | 112 | return gulp.watch([paths.srcJS, paths.srcViews], ['copy']); |
112 | }); | 113 | }); |
113 | 114 |