Commit c83ab18ae41a99acd09c51948e63eeade577a964
1 parent
464933eea0
Exists in
master
- Agregué tareas gulp.
- code styling.
Showing
1 changed file
with
11 additions
and
2 deletions
Show diff stats
gulpfile.js
1 | const templateCache = require('gulp-angular-templatecache'); | 1 | const templateCache = require('gulp-angular-templatecache'); |
2 | const concat = require('gulp-concat'); | 2 | const concat = require('gulp-concat'); |
3 | const htmlmin = require('gulp-htmlmin'); | 3 | const htmlmin = require('gulp-htmlmin'); |
4 | const rename = require('gulp-rename'); | 4 | const rename = require('gulp-rename'); |
5 | const uglify = require('gulp-uglify'); | 5 | const uglify = require('gulp-uglify'); |
6 | const gulp = require('gulp'); | 6 | const gulp = require('gulp'); |
7 | const pump = require('pump'); | 7 | const pump = require('pump'); |
8 | const jshint = require('gulp-jshint'); | 8 | const jshint = require('gulp-jshint'); |
9 | const replace = require('gulp-replace'); | 9 | const replace = require('gulp-replace'); |
10 | const connect = require('gulp-connect'); | 10 | const connect = require('gulp-connect'); |
11 | const clean = require('gulp-clean'); | 11 | const clean = require('gulp-clean'); |
12 | 12 | ||
13 | var paths = { | 13 | var paths = { |
14 | srcJS: 'src/js/*.js', | 14 | srcJS: 'src/js/*.js', |
15 | srcViews: 'src/views/*.html', | 15 | srcViews: 'src/views/*.html', |
16 | tmp: 'tmp', | 16 | tmp: 'tmp', |
17 | dist: 'dist/' | 17 | dist: 'dist/' |
18 | }; | 18 | }; |
19 | 19 | ||
20 | gulp.task('clean', function() { | 20 | gulp.task('clean', function() { |
21 | return gulp.src(['tmp', 'dist'], {read: false}) | 21 | return gulp.src(['tmp', 'dist'], {read: false}) |
22 | .pipe(clean()); | 22 | .pipe(clean()); |
23 | }); | 23 | }); |
24 | 24 | ||
25 | gulp.task('templates', ['clean'], function() { | 25 | gulp.task('templates', ['clean'], function() { |
26 | return pump( | 26 | return pump( |
27 | [ | 27 | [ |
28 | gulp.src(paths.srcViews), | 28 | gulp.src(paths.srcViews), |
29 | htmlmin(), | 29 | htmlmin(), |
30 | templateCache('views.js', { | 30 | templateCache('views.js', { |
31 | module: 'focaBotoneraPrincipal', | 31 | module: 'focaBotoneraPrincipal', |
32 | root: '' | 32 | root: '' |
33 | }), | 33 | }), |
34 | gulp.dest(paths.tmp) | 34 | gulp.dest(paths.tmp) |
35 | ] | 35 | ] |
36 | ); | 36 | ); |
37 | }); | 37 | }); |
38 | 38 | ||
39 | gulp.task('uglify', ['templates'], function() { | 39 | gulp.task('uglify', ['templates'], function() { |
40 | return pump( | 40 | return pump( |
41 | [ | 41 | [ |
42 | gulp.src([ | 42 | gulp.src([ |
43 | paths.srcJS, | 43 | paths.srcJS, |
44 | 'tmp/views.js' | 44 | 'tmp/views.js' |
45 | ]), | 45 | ]), |
46 | concat('foca-botonera-principal.js'), | 46 | concat('foca-botonera-principal.js'), |
47 | replace('src/views/', ''), | 47 | replace('src/views/', ''), |
48 | gulp.dest(paths.tmp), | 48 | gulp.dest(paths.tmp), |
49 | rename('foca-botonera-principal.min.js'), | 49 | rename('foca-botonera-principal.min.js'), |
50 | uglify(), | 50 | uglify(), |
51 | gulp.dest(paths.dist) | 51 | gulp.dest(paths.dist) |
52 | ] | 52 | ] |
53 | ); | 53 | ); |
54 | }); | 54 | }); |
55 | 55 | ||
56 | gulp.task('pre-commit', function() { | 56 | gulp.task('pre-commit', function() { |
57 | return pump( | 57 | return pump( |
58 | [ | 58 | [ |
59 | gulp.src(paths.srcJS), | 59 | gulp.src(paths.srcJS), |
60 | jshint('.jshintrc'), | 60 | jshint('.jshintrc'), |
61 | jshint.reporter('default'), | 61 | jshint.reporter('default'), |
62 | jshint.reporter('fail') | 62 | jshint.reporter('fail') |
63 | ] | 63 | ] |
64 | ); | 64 | ); |
65 | 65 | ||
66 | gulp.start('uglify'); | 66 | gulp.start('uglify'); |
67 | }); | 67 | }); |
68 | 68 | ||
69 | gulp.task('webserver', function() { | 69 | gulp.task('webserver', function() { |
70 | pump [ | 70 | pump [ |
71 | connect.server({port: 3000}) | 71 | connect.server({port: 3000}) |
72 | ] | 72 | ] |
73 | }); | 73 | }); |
74 | 74 | ||
75 | gulp.task('clean-post-install', function(){ | 75 | gulp.task('clean-post-install', function() { |
76 | return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js', | 76 | return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js', |
77 | 'index.html'], {read: false}) | 77 | 'index.html'], {read: false}) |
78 | .pipe(clean()); | 78 | .pipe(clean()); |
79 | }); | 79 | }); |
80 | 80 | ||
81 | gulp.task('default', ['webserver']); | 81 | gulp.task('default', ['webserver']); |
82 | 82 | ||
83 | gulp.task('watch', function() { | 83 | gulp.task('watch', function() { |
84 | gulp.watch([paths.srcJS, paths.srcViews], ['uglify']) | 84 | return gulp.watch([paths.srcJS, paths.srcViews], ['uglify']) |
85 | }); | ||
86 | |||
87 | gulp.task('copy', ['uglify'], function() { | ||
88 | return gulp.src('dist/*.js') | ||
89 | .pipe(gulp.dest('../../wrapper-demo/node_modules/foca-botonera-principal/dist/')); | ||
90 | }); | ||
91 | |||
92 | gulp.task('watchAndCopy', function() { | ||
93 | return gulp.watch([paths.srcJS, paths.srcViews], ['copy']); | ||
85 | }); | 94 | }); |
86 | 95 |