Skip to content

Commit

Permalink
ajustamos el buildeo de los entornos, con handlebars en el medio. Agr…
Browse files Browse the repository at this point in the history
…egamos tareas de limpieza para dist y build
  • Loading branch information
dudesl committed May 18, 2016
1 parent 8ec5e6c commit 616f76f
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 26 deletions.
22 changes: 22 additions & 0 deletions build/styles/base.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build/styles/maps/base.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

59 changes: 45 additions & 14 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
var gulp = require('gulp');
var util = require('gulp-util');
var browserSync = require('browser-sync');
var reload = browserSync.reload;
var inlineCss = require('gulp-inline-css');
var sass = require('gulp-sass');
var runSequence = require('run-sequence');
var sourcemaps = require('gulp-sourcemaps');
var gulp = require('gulp'),
$ = require('gulp-load-plugins')(),
browserSync = require('browser-sync'),
del = require('del'),
reload = browserSync.reload,
runSequence = require('run-sequence')

var src = {
'base' : 'src',
Expand Down Expand Up @@ -36,22 +34,45 @@ gulp.task('serve', ['build'], function() {
gulp.watch('*.html', ['build']).on('change', reload);;
});

gulp.task('compileBuild', function () {
// Hacer variable el archivo de datos
// Acá en lugar de leer un archivo se puede hacer una llamada a una api con algun módulo externo
// var templateData = JSON.parse(fs.readFileSync(src.content + '/data_rsys_MLC.json')),
var templateData = {},
options = {
ignorePartials: true, //ignores the unknown footer2 partial in the handlebars template, defaults to false
// batch : src.components
// partials : {
// footer : '<footer>{{{banner_mobile_title}}}</footer>'
// },
// helpers : {
// capitals : function(str){
// return str.toUpperCase();
// }
// }
}

return gulp.src(src.base + '/*.html')
.pipe($.compileHandlebars(templateData, options))
.pipe(gulp.dest(build.base));
});

// Compile scss into CSS & auto-inject into browsers
gulp.task('scssBuild', function() {
return gulp.src(src.styles + '/**/*.scss')
.pipe(sourcemaps.init())
.pipe(sass({
.pipe($.sourcemaps.init())
.pipe($.sass({
onError: console.error.bind(console, 'Sass error:')
}))
.pipe(sourcemaps.write('maps'))
.pipe($.sourcemaps.write('maps'))
.pipe(gulp.dest(build.styles))
.pipe(browserSync.stream());
});

// Inline CSS
gulp.task('inlineDist', function() {
return gulp.src(build.base + '/*.html')
.pipe(inlineCss({
.pipe($.inlineCss({
preserveMediaQueries: true,
applyStyleTags: true,
applyLinkTags: true
Expand All @@ -65,14 +86,24 @@ gulp.task('imageBuild', function() {
.pipe(gulp.dest(build.images))
});


gulp.task('cleanBuild', function() {
del.sync([build.base + '*']);
});

gulp.task('cleanDist', function() {
del.sync([dist.base + '*']);
});


gulp.task('build', function () {
runSequence(
'scssBuild', 'imageBuild'
'cleanBuild', 'scssBuild', 'imageBuild', 'compileBuild'
)
})

gulp.task('dist', function () {
runSequence(
'inlineDist'
'cleanDist', 'inlineDist'
)
})
17 changes: 10 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
{
"name": "<%= mailName %>",
"version": "<%= mailVersion %>",
"description": "<%= mailDescription %>",
"author": "<%= authorName %>",
"name": "email-enviroment",
"version": "0.2.0",
"description": "An enviroment to compose an email",
"author": "Santiago Barchetta <[email protected]",
"license": "ISC",
"repository" : {
"type" : "git",
"url" : "<%= repositoryURL %>"
"repository": {
"type": "git",
"url": "https://github.com/dudesl/email-enviroment"
},
"dependencies": {
"browser-sync": "^2.10.0",
"del": "^2.2.0",
"gulp": "^3.9.0",
"gulp-compile-handlebars": "^0.6.1 ",
"gulp-inline-css": "^3.0.0",
"gulp-load-plugins": "^1.2.2",
"gulp-sass": "^2.1.0",
"gulp-sourcemaps": "^1.6.0",
"gulp-util": "^3.0.7",
Expand Down
19 changes: 15 additions & 4 deletions send.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
var http = require('http');
var mailgun = require('mailgun-js')({
// configuración de una cuenta própia en mailgun.
// Por el momento se puede usar sin problema.
apiKey: 'key-f1d1f5a41e5528beaeb63f35b6a7c80c',
domain: 'sandboxd2cba16debb04c3a9d37570b82f0c884.mailgun.org'
// apiKey: 'key',
// domain: 'sandbox'
});

var url = 'http://localhost:3000';
var body = '';

var data = {
from: 'Mailgun Postmaster <[email protected]>',
subject: '[TEST] Email Marketing',
subject: '[TEST] Email Test',
// Dirección de Litmus para generar un nuevo checklist de prueba
// Se pueden agregar sucesivas direcciones email1@test.com, [email protected], [email protected]
to: '[email protected]'
}

Expand All @@ -26,7 +28,16 @@ http.get(url, function(res) {

res.on("end", function () {
data.html = body;
mailgun.messages().send(data, function (err, body) {})
mailgun.messages().send(data, function (err, body) {
if (!err) {
console.log('Email sended [res code: '+ res.statusCode + ']')
console.log('Status : ' + res.statusCode)
} else {
console.log('Error en el envío del mail.');
console.log('[Error obj: ' + err +']');
console.log('[res code: '+ res.statusCode + ']');
}
})
});

} else {
Expand Down

0 comments on commit 616f76f

Please sign in to comment.