11var autoprefixer = require ( 'gulp-autoprefixer' ) ,
2+ batch = require ( 'gulp-batch' ) ,
23 concat = require ( 'gulp-concat' ) ,
34 gulp = require ( 'gulp' ) ,
5+ gutil = require ( 'gulp-util' ) ,
46 minifyCSS = require ( 'gulp-minify-css' ) ,
7+ newer = require ( 'gulp-newer' ) ,
8+ sourcemaps = require ( 'gulp-sourcemaps' ) ,
59 watch = require ( 'gulp-watch' ) ;
610
7- var _ = require ( "underscore" ) ,
8- glob = require ( "glob" ) ,
9- minimatch = require ( "minimatch" ) ;
11+ var browserify = require ( 'browserify' ) ,
12+ browserSync = require ( 'browser-sync' ) ,
13+ buffer = require ( 'vinyl-buffer' ) ,
14+ map = require ( 'vinyl-map' ) ,
15+ mainBowerFiles = require ( 'main-bower-files' ) ,
16+ source = require ( 'vinyl-source-stream' ) ;
1017
11- function getFiles ( path ) {
12- var files = glob . sync ( path + '**/*.css' ) ;
13- target = minimatch . match ( files , '__*.css' , { matchBase : true } ) ;
14- ignore = _ . map ( target , function ( item ) { return '!' + item ; } ) ;
15- result = files . concat ( ignore ) ;
16- return result ;
17- }
18+ gulp . task ( 'browser-sync' , function ( ) {
19+ browserSync ( {
20+ proxy : "127.0.0.1:6543" ,
21+ logLevel : "silent" ,
22+ } ) ;
23+ } ) ;
1824
19- gulp . task ( 'css' , function ( ) {
25+ gulp . task ( 'bower' , function ( ) {
26+ gulp . src ( mainBowerFiles ( { filter : ( / .* \. p n g $ / i) } ) , { base : 'bower_components' } )
27+ . pipe ( gulp . dest ( './pyramid_sacrud_pages/static/css/__bower_components/' ) )
28+ . pipe ( map ( function ( code , filename ) { gutil . log ( 'Bower Images ' + gutil . colors . green ( filename ) ) ;
29+ } ) )
30+ gulp . src ( mainBowerFiles ( { filter : ( / .* \. c s s $ / i) } ) , { base : 'bower_components' } )
31+ . pipe ( gulp . dest ( './pyramid_sacrud_pages/static/css/__bower_components/' ) )
32+ . pipe ( map ( function ( code , filename ) { gutil . log ( 'Bower CSS ' + gutil . colors . green ( filename ) ) ;
33+ } ) )
34+ } ) ;
2035
21- var path = glob . sync ( './*/static/css/' ) ,
22- concatFiles = getFiles ( path ) ;
36+ gulp . task ( 'browserify' , function ( ) {
37+ browserify ( './pyramid_sacrud_pages/static/js/main.js' )
38+ . bundle ( )
39+ . pipe ( source ( '__pyramid_sacrud_pages.js' ) )
40+ . pipe ( buffer ( ) )
41+ . pipe ( sourcemaps . init ( { loadMaps : true } ) )
42+ . pipe ( sourcemaps . write ( './' ) )
43+ . pipe ( gulp . dest ( './pyramid_sacrud_pages/static/js/' ) )
44+ . pipe ( map ( function ( code , filename ) { gutil . log ( 'Browserify ' + gutil . colors . green ( filename ) ) ; } ) )
45+ . pipe ( browserSync . reload ( { stream :true } ) ) ;
46+ } ) ;
2347
24- gulp . src ( concatFiles )
48+ gulp . task ( 'css' , function ( ) {
49+ path = [ './pyramid_sacrud_pages/static/css/*.css' ,
50+ './pyramid_sacrud_pages/static/css/**/*.css' ,
51+ '!./pyramid_sacrud_pages/static/css/__pyramid_sacrud_pages.css' ] ;
52+ gulp . src ( path )
53+ . pipe ( newer ( './pyramid_sacrud_pages/static/css/__pyramid_sacrud_pages.css' ) )
54+ . pipe ( sourcemaps . init ( ) )
2555 . pipe ( autoprefixer ( {
26- browsers : [
27- 'Firefox >= 3' ,
28- 'Explorer >= 6' ,
29- 'Opera >= 9' ,
30- 'Chrome >= 15' ,
31- 'Safari >= 4' ,
32- '> 1%' ] ,
56+ browsers : [ 'Firefox >= 3' , 'Explorer >= 6' , 'Opera >= 9' , 'Chrome >= 15' , 'Safari >= 4' , '> 1%' ] ,
3357 cascade : false
3458 } ) )
59+ . on ( 'error' , function ( err ) {
60+ gutil . log ( gutil . colors . red ( 'Autoprefixer Error' ) , gutil . colors . yellow ( err . message ) ) ;
61+ } )
3562 . pipe ( minifyCSS ( ) )
36- . pipe ( concat ( '__pages.css' ) )
37- . pipe ( gulp . dest ( path + '/' ) ) ;
63+ . pipe ( concat ( '__pyramid_sacrud_pages.css' ) )
64+ . pipe ( sourcemaps . write ( '.' ) )
65+ . pipe ( gulp . dest ( './pyramid_sacrud_pages/static/css/' ) )
66+ . pipe ( map ( function ( code , filename ) { gutil . log ( 'CSS ' + gutil . colors . green ( filename ) ) ; } ) )
67+ . on ( 'error' , gutil . log )
68+ . pipe ( browserSync . reload ( { stream :true } ) ) ;
3869} ) ;
3970
40- gulp . task ( 'watch' , function ( ) {
41-
42- var path = glob . sync ( './*/static/*/' ) ,
43- watchFiles = getFiles ( path ) ;
44-
45- watch ( watchFiles , function ( files ) {
46- gulp . start ( 'css' , cb ) ;
47- } ) ;
71+ gulp . task ( 'watch' , function ( ) {
72+ watch ( [ './pyramid_sacrud_pages/static/css/*.css' ,
73+ './pyramid_sacrud_pages/static/css/**/*.css' ,
74+ '!./pyramid_sacrud_pages/static/css/__pyramid_sacrud_pages.css' ] , { verbose : true } , batch ( function ( ) {
75+ gulp . start ( 'css' ) ;
76+ } ) ) ;
77+ watch ( [ './pyramid_sacrud_pages/static/js/*.js' ,
78+ './pyramid_sacrud_pages/static/js/**/*.js' ,
79+ '!./pyramid_sacrud_pages/static/js/__pyramid_sacrud_pages.js' ] , { verbose : true } , batch ( function ( ) {
80+ gulp . start ( 'browserify' ) ;
81+ } ) ) ;
4882} ) ;
4983
50- gulp . task ( 'default' , [ 'watch' ] ) ;
84+ gulp . task ( 'default' , [ 'watch' , 'browser-sync' ] ) ;
0 commit comments