Created
July 29, 2015 18:46
-
-
Save raank/540c2f0de033acb6c86a to your computer and use it in GitHub Desktop.
WP THEME: Gulpfile.js e Package Json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
var gulp = require( "gulp" ); | |
var plugins = require( "gulp-load-plugins" )({ lazy: false }); | |
/******************** | |
* Task dos estilos | |
********************/ | |
gulp.task("styles", function() { | |
gulp.src("assets/sass/**/*.scss") | |
/** | |
* Compila o SASS | |
*/ | |
.pipe( plugins.rubySass({ | |
loadPath : ["bower_components"], // plugins adicionais do bower, usando " //import("pasta/do/script.js") " | |
noCache : true, // sem cache | |
compass : false, // Compass | |
style : "compressed", // Minificado | |
trace : true, | |
"sourcemap=none": true // Source Maps | |
})) | |
/** | |
* Insere fallbacks para navegadores automaticamente | |
*/ | |
.pipe( plugins.autoprefixer( [ "last 2 version", "> 1%", "ie 8", "ie 7" ], { cascade: false })) | |
/** | |
* Renomeia os arquivos {arquivo}.min.css | |
*/ | |
.pipe( plugins.rename({ suffix: ".min" })) | |
/** | |
* Minifica o css | |
*/ | |
.pipe( plugins.minifyCss() ) | |
/** | |
* Local onde será salvado o arquivo compilado | |
*/ | |
.pipe( gulp.dest( "build/css" )) | |
}); | |
/******************** | |
* Task dos scripts | |
********************/ | |
gulp.task("scripts", function() { | |
gulp.src([ | |
"assets/js/**/*.js", // Scripts para serem minificados | |
"!assets/js/**/_*.js" // Scripts que não devem ser minificados | |
]) | |
/** | |
* Local onde o import deve buscar | |
*/ | |
.pipe( plugins.dynamic({ paths: ["bower_components"] })) | |
/** | |
* Minifica o JS | |
*/ | |
.pipe( plugins.uglify() ) | |
/** | |
* Renomeia os arquivos {arquivo}.min.js | |
*/ | |
.pipe( plugins.rename({ suffix: ".min" })) | |
/** | |
* Local onde será salvado o arquivo compilado | |
*/ | |
.pipe( gulp.dest("build/js") ) | |
}); | |
/******************** | |
* Task das imagens | |
* ATENÇÃO: essa task apenas copia as imagens para a pasta /build/images/ | |
********************/ | |
gulp.task("images", function() { | |
gulp.src(["build/images/**/*.{png,jpg,gif"]) | |
.pipe( gulp.dest("build/images") ) | |
}); | |
/******************** | |
* Task para "assistir" a pasta assets, caso tiver alguma alteração, será rodada task referente ao arquivo. | |
********************/ | |
gulp.task('watch', function() { | |
gulp.watch(['assets/sass/**/*.scss'], ['styles']); | |
gulp.watch(['assets/js/**/*.js'], ['scripts']); | |
gulp.watch(['assets/images/**/*.{jpg,png.gif}'], ['images']); | |
}); | |
/******************** | |
* Gera a build com o comando " gulp build " | |
********************/ | |
gulp.task('build', ['styles', 'scripts', 'images']); | |
/******************** | |
* default (gulp) | |
********************/ | |
gulp.task('default', ['watch']); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "wp-theme", | |
"version": "1.0.0", | |
"title": "Simples tema wordpress", | |
"author": "Raank (http://raank.github.io)", | |
"dependencies": { | |
"gulp": "", | |
"gulp-autoprefixer": "", | |
"gulp-dynamic": "", | |
"gulp-load-plugins": "", | |
"gulp-minify-css": "", | |
"gulp-rename": "", | |
"gulp-ruby-sass": "0.7.1", | |
"gulp-uglify": "", | |
"path": "" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment