Skip to content

Instantly share code, notes, and snippets.

@adeonir
Last active May 28, 2018 17:25
Show Gist options
  • Save adeonir/4d2f652f5a00b2124b4f640fe268a0c8 to your computer and use it in GitHub Desktop.
Save adeonir/4d2f652f5a00b2124b4f640fe268a0c8 to your computer and use it in GitHub Desktop.

Revisions

  1. adeonir revised this gist May 28, 2018. 1 changed file with 1 addition and 3 deletions.
    4 changes: 1 addition & 3 deletions gulpfile.js
    Original file line number Diff line number Diff line change
    @@ -92,9 +92,7 @@ gulp.task('deploy', () => {
    parallel: 10,
    });

    const globs = ['./_site/**'];

    return gulp.src(globs, { base: '.', buffer: false })
    return gulp.src('_site/**', { base: '_site/', buffer: false })
    .pipe(conn.newer('/public_html'))
    .pipe(conn.dest('/public_html'));
    });
  2. adeonir revised this gist May 28, 2018. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions gulpfile.js
    Original file line number Diff line number Diff line change
    @@ -86,9 +86,9 @@ gulp.task('watch', () => {

    gulp.task('deploy', () => {
    const conn = ftp.create({
    host: 'ftp.tralog.com.br',
    user: 'tralog1',
    pass: 'ford2018!',
    host: '',
    user: '',
    pass: '',
    parallel: 10,
    });

  3. adeonir created this gist May 28, 2018.
    104 changes: 104 additions & 0 deletions gulpfile.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,104 @@
    const gulp = require('gulp');
    const yargs = require('yargs');
    const plumber = require('gulp-plumber');
    const sass = require('gulp-sass');
    const postcss = require('gulp-postcss');
    const autoprefixer = require('autoprefixer');
    const cssnano = require('cssnano');
    const svgmin = require('gulp-svgmin');
    const rename = require('gulp-rename');
    const babel = require('gulp-babel');
    const minify = require('gulp-babel-minify');
    const ftp = require('vinyl-ftp');
    const browserSync = require('browser-sync');
    const childProcess = require('child_process');

    const deploy = Boolean(yargs.argv.production);

    gulp.task('jekyll', (done) => {
    if (deploy) {
    const production = process.env;
    production.JEKYLL_ENV = 'production';

    return childProcess.spawn('jekyll', ['build'], { stdio: 'inherit', env: production })
    .on('close', done);
    }

    return childProcess.spawn('jekyll', ['build'], { stdio: 'inherit' })
    .on('close', done);
    });

    gulp.task('rebuild', ['jekyll'], () => {
    browserSync.reload();
    });

    gulp.task('browser-sync', ['jekyll'], () => {
    browserSync({
    server: {
    baseDir: '_site',
    },
    });
    });

    gulp.task('styles', () => {
    gulp.src('src/sass/main.scss')
    .pipe(plumber())
    .pipe(sass())
    .pipe(postcss([autoprefixer(), cssnano()]))
    .pipe(gulp.dest('_site/assets/css/'))
    .pipe(browserSync.reload({ stream: true }))
    .pipe(gulp.dest('assets/css/'));
    });

    gulp.task('scripts', () => {
    gulp.src('src/js/*.js')
    .pipe(plumber())
    .pipe(babel())
    .pipe(minify())
    .pipe(gulp.dest('_site/assets/js/'))
    .pipe(browserSync.reload({ stream: true }))
    .pipe(gulp.dest('assets/js/'));
    });

    gulp.task('images', () => {
    gulp.src('src/img/**/*')
    .pipe(gulp.dest('_site/assets/img/'))
    .pipe(browserSync.reload({ stream: true }))
    .pipe(gulp.dest('assets/img/'));
    });

    gulp.task('vectors', () => {
    gulp.src('src/svg/**/*')
    .pipe(plumber())
    .pipe(svgmin())
    .pipe(rename({
    extname: '.html',
    }))
    .pipe(gulp.dest('_includes/'))
    .pipe(browserSync.reload({ stream: true }));
    });

    gulp.task('watch', () => {
    gulp.watch('src/sass/**/*', ['styles', 'rebuild']);
    gulp.watch('src/js/*.js', ['scripts', 'rebuild']);
    gulp.watch(['**/*.html', '_includes/*.html', '_layouts/*.html'], ['rebuild']);
    });

    gulp.task('deploy', () => {
    const conn = ftp.create({
    host: 'ftp.tralog.com.br',
    user: 'tralog1',
    pass: 'ford2018!',
    parallel: 10,
    });

    const globs = ['./_site/**'];

    return gulp.src(globs, { base: '.', buffer: false })
    .pipe(conn.newer('/public_html'))
    .pipe(conn.dest('/public_html'));
    });

    gulp.task('dev', ['images', 'vectors', 'styles', 'scripts', 'browser-sync', 'watch']);

    gulp.task('build', ['images', 'vectors', 'styles', 'scripts', 'jekyll']);