Commit 84c97e937c267ac1ea95221228dd51af3b057adf
1 parent
8783bb386e
Exists in
master
code review.
Showing
1 changed file
with
2 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: 'focaModalNotaPedido', | 31 | module: 'focaModalNotaPedido', |
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-modal-nota-pedido.js'), | 46 | concat('foca-modal-nota-pedido.js'), |
47 | replace('src/views/', ''), | 47 | replace('src/views/', ''), |
48 | replace("['ui.bootstrap', 'focaDirectivas', 'angular-ladda']", '[]'), | 48 | replace("['ui.bootstrap', 'focaDirectivas', 'angular-ladda']", '[]'), |
49 | gulp.dest(paths.tmp), | 49 | gulp.dest(paths.tmp), |
50 | rename('foca-modal-nota-pedido.min.js'), | 50 | rename('foca-modal-nota-pedido.min.js'), |
51 | uglify(), | 51 | uglify(), |
52 | gulp.dest(paths.dist) | 52 | gulp.dest(paths.dist) |
53 | ] | 53 | ] |
54 | ); | 54 | ); |
55 | }); | 55 | }); |
56 | 56 | ||
57 | gulp.task('pre-commit', function() { | 57 | gulp.task('pre-commit', function() { |
58 | return pump( | 58 | return pump( |
59 | [ | 59 | [ |
60 | gulp.src(paths.srcJS), | 60 | gulp.src(paths.srcJS), |
61 | jshint('.jshintrc'), | 61 | jshint('.jshintrc'), |
62 | jshint.reporter('default'), | 62 | jshint.reporter('default'), |
63 | jshint.reporter('fail') | 63 | jshint.reporter('fail') |
64 | ] | 64 | ] |
65 | ); | 65 | ); |
66 | 66 | ||
67 | gulp.start('uglify'); | 67 | gulp.start('uglify'); |
68 | }); | 68 | }); |
69 | 69 | ||
70 | gulp.task('webserver', function() { | 70 | gulp.task('webserver', function() { |
71 | pump [ | 71 | pump [ |
72 | connect.server({port: 3000}) | 72 | connect.server({port: 3000}) |
73 | ] | 73 | ] |
74 | }); | 74 | }); |
75 | 75 | ||
76 | gulp.task('clean-post-install', function(){ | 76 | gulp.task('clean-post-install', function() { |
77 | return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js', | 77 | return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js', |
78 | 'index.html'], {read: false}) | 78 | 'index.html'], {read: false}) |
79 | .pipe(clean()); | 79 | .pipe(clean()); |
80 | }); | 80 | }); |
81 | 81 | ||
82 | gulp.task('default', ['webserver']); | 82 | gulp.task('default', ['webserver']); |
83 | 83 | ||
84 | gulp.task('watch', function() { | 84 | gulp.task('watch', function() { |
85 | gulp.watch([paths.srcJS, paths.srcViews], ['uglify']) | 85 | gulp.watch([paths.srcJS, paths.srcViews], ['uglify']) |
86 | }); | 86 | }); |
87 | 87 | ||
88 | gulp.task('copy', ['uglify'], function(){ | 88 | gulp.task('copy', ['uglify'], function() { |
89 | gulp.src('dist/*.js') | 89 | gulp.src('dist/*.js') |
90 | .pipe(gulp.dest('../../wrapper-demo/node_modules/foca-modal-nota-pedido/dist')); | 90 | .pipe(gulp.dest('../../wrapper-demo/node_modules/foca-modal-nota-pedido/dist')); |
91 | }); | 91 | }); |
92 | 92 | ||
93 | gulp.task('watchAndCopy', function() { | 93 | gulp.task('watchAndCopy', function() { |
94 | return gulp.watch([paths.srcJS, paths.srcViews], ['copy']); | 94 | return gulp.watch([paths.srcJS, paths.srcViews], ['copy']); |
95 | }); | 95 | }); |
96 | 96 |