| 1 |  |  | 'use strict'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | // Useful vars for configuring in your environment | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  | /*-------------------------------------------------------------------------------------------------*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | // var parentThemeRoot  = "../../../vendor/erdiko/wordpress/themes/clean-blog/"; // for themes updated with composer | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | var renderedThemeRoot  = "../../public/"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | var themeName       = "bootstrap"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | var renderedTheme   = renderedThemeRoot+'themes/'+themeName; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | var jQueryJs        = "node_modules/jquery/dist/jquery.slim.js"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | var tetherJs        = "node_modules/tether/dist/js/tether.js"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | var bootstrapJs     = "node_modules/bootstrap-v4-dev/dist/js/bootstrap.js"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | // var cleanBlogJs     = parentThemeRoot+"scripts/clean-blog.js"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | // Boilerplate & Setup | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | /*-------------------------------------------------------------------------------------------------*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  | var gulp = require('gulp'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  | // load plugins from package.json file | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  | var $ = require('gulp-load-plugins')(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |     $.del = require('del'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |     $.runSequence = require('run-sequence'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  | // Make 'build' the default task | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  | gulp.task('default', function() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |    gulp.start('build'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  | }); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  | // Notify when build is complete | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  | gulp.task('notify:buildComplete', function(callback) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |    $.notify().write("Build Complete"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |    callback(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  | }); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  | // Empty 'stage' directory so we can start fresh | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  | gulp.task('clean:stage', function(callback) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |    $.del([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |       'stage/**/*', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |   ], callback); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  | }); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  | // Main Tasks | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  | /*-------------------------------------------------------------------------------------------------*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  | // build - The main task that runs all subtasks | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  | gulp.task('build', function(callback) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |    $.runSequence( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |       'clean:stage', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |       ['styles', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |           'tether-scripts', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |           'bootstrap-scripts', 'jquery-scripts', 'scripts'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |       ['minify-css', 'minify-js'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |       'notify:buildComplete', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |       callback | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |    ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  | }); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  | // Subtasks | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  | /*-------------------------------------------------------------------------------------------------*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  | // Compile SASS | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  | gulp.task('styles', function(callback) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |    return gulp.src('styles/**/*.scss') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |       .pipe($.order([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |           "styles.css", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |           "**/*.scss" | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |       ])) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |       // Load existing internal sourcemap | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |       .pipe($.sourcemaps.init()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |       // generate CSS from SASS | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |       .pipe($.sass()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |       // Catch any errors and prevent them from crashing gulp | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |       .on('error', function (error) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |          $.notify().write(error); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |          this.emit('end'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |       }) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |       // autoprefix CSS using bootstrap standards | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |       .pipe($.autoprefixer({ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |          browsers: [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |             "Android 2.3", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |             "Android >= 4", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |             "Chrome >= 20", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |             "Firefox >= 24", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |             "Explorer >= 8", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |             "iOS >= 6", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |             "Opera >= 12", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |             "Safari >= 6" | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |          ], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |          remove: false | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |       })) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |       // Write final .map file | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |       .pipe($.sourcemaps.write()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |       // move files to stage | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |       .pipe(gulp.dest('stage/styles'), callback); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  | }); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  | // Javascript | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  | gulp.task('scripts', function(callback) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |    return gulp.src('scripts/**/*.js') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |       // copy scripts to stage | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |       .pipe(gulp.dest('stage/scripts'), callback); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  | }); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |  | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 111 |  |  | // Tether Javascript | 
            
                                                                        
                            
            
                                    
            
            
                | 112 |  |  | gulp.task('tether-scripts', function(callback) { | 
            
                                                                        
                            
            
                                    
            
            
                | 113 |  |  |    return gulp.src(tetherJs) | 
            
                                                                        
                            
            
                                    
            
            
                | 114 |  |  |       // copy scripts to stage | 
            
                                                                        
                            
            
                                    
            
            
                | 115 |  |  |       .pipe(gulp.dest('stage/scripts/vendor'), callback); | 
            
                                                                        
                            
            
                                    
            
            
                | 116 |  |  | }); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  | // Bootstrap Javascript | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  | gulp.task('bootstrap-scripts', function(callback) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |    return gulp.src(bootstrapJs) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |       // copy scripts to stage | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |       .pipe(gulp.dest('stage/scripts/vendor'), callback); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  | }); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  | // jQuery Javascript | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  | gulp.task('jquery-scripts', function(callback) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |    return gulp.src(jQueryJs) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |       // copy scripts to stage | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |       .pipe(gulp.dest('stage/scripts/vendor'), callback); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  | }); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  | // Minify CSS and put it in the public dir | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  | gulp.task('minify-css', function() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |   return gulp.src('stage/styles/**/*.css') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |      .pipe($.cleanCss({ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |         processImport: false | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |      })) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |      .pipe($.rename({ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |         basename: 'main', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |         suffix: '.min', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  |         extname: '.css' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  |      })) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  |     .pipe(gulp.dest(renderedTheme+'/css')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  | }); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  | // minify JS and put in the public dir | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  | gulp.task('minify-js', function () { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  |    return gulp.src(['stage/scripts/**/*.js']) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  |       .pipe($.order([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |         "vendor/jquery.slim.js", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  |         "vendor/tether.js", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  |         "vendor/bootstrap.js", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  |         "vendor/*.js", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  |         "**/*.js" | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |       ])) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  |       .pipe($.concat('scripts.min.js')) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |       .pipe($.uglify()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  |       .pipe(gulp.dest(renderedTheme+'/js')); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 160 |  |  | }); | 
            
                                                        
            
                                    
            
            
                | 161 |  |  |  |