Update a few packages

This commit is contained in:
Brittany Chiang
2018-10-03 22:20:28 -04:00
parent 36fd3c4d02
commit ea2515df7e
7 changed files with 595 additions and 386 deletions

View File

@@ -1,23 +1,30 @@
const browserSync = require('browser-sync').create();
const cp = require('child_process');
const browserSync = require('browser-sync').create();
const cp = require('child_process');
const jekyll = process.platform === 'win32' ? 'jekyll.bat' : 'jekyll';
const jekyll = process.platform === 'win32' ? 'jekyll.bat' : 'jekyll';
const scssPath = '_scss/**/*.scss';
const jsPath = '_scripts/*.js';
const templatePath = ['*.html', '+(_includes|_layouts)/*.html', '*.yml', '_data/*.yml', '_posts/*'];
const scssPath = '_scss/**/*.scss';
const jsPath = '_scripts/*.js';
const templatePath = [
'*.html',
'+(_includes|_layouts)/*.html',
'*.yml',
'_data/*.yml',
'_posts/*',
];
module.exports = gulp => {
// run `jekyll build`
gulp.task('jekyll-build', done => {
return cp.spawn(jekyll, ['build'], {stdio: 'inherit'})
.on('close', done);
return cp.spawn(jekyll, ['build'], { stdio: 'inherit' }).on('close', done);
});
// run `jekyll build` with _config_dev.yml
gulp.task('jekyll-dev', done => {
return cp.spawn(jekyll, ['build', '--config', '_config.yml,_config_dev.yml'], {stdio: 'inherit'})
return cp
.spawn(jekyll, ['build', '--config', '_config.yml,_config_dev.yml'], {
stdio: 'inherit',
})
.on('close', done);
});
@@ -29,13 +36,12 @@ module.exports = gulp => {
gulp.task('serve', ['jekyll-dev'], () => {
browserSync.init({
server: {
baseDir: '_site'
}
baseDir: '_site',
},
});
gulp.watch(scssPath, ['sass', browserSync.reload]);
gulp.watch(jsPath, ['scripts', browserSync.reload]);
gulp.watch(templatePath, ['jekyll-rebuild']);
});
};

View File

@@ -4,11 +4,10 @@ const imgPath = 'img/**/*.+(png|jpg|gif|svg)';
const destPath = '_site/img';
module.exports = gulp => {
gulp.task('images', () => {
return gulp.src(imgPath)
return gulp
.src(imgPath)
.pipe(imagemin())
.pipe(gulp.dest(destPath));
});
};

View File

@@ -1,25 +1,28 @@
const sass = require('gulp-sass');
const prefix = require('gulp-autoprefixer');
const cleanCSS = require('gulp-clean-css');
const sass = require('gulp-sass');
const prefix = require('gulp-autoprefixer');
const cleanCSS = require('gulp-clean-css');
const scssPath = '_scss/*.scss';
const destPath = '_site/css';
const scssPath = '_scss/*.scss';
const destPath = '_site/css';
module.exports = gulp => {
gulp.task('sass', () => {
return gulp.src(scssPath)
.pipe(sass({
includePaths: ['scss'],
outputStyle: 'expanded'
}))
.pipe(prefix({
browsers: ['last 2 versions'],
cascade: false
}))
return gulp
.src(scssPath)
.pipe(
sass({
includePaths: ['scss'],
outputStyle: 'expanded',
})
)
.pipe(
prefix({
browsers: ['last 2 versions'],
cascade: false,
})
)
.pipe(cleanCSS({ compatibility: 'ie8' }))
.pipe(gulp.dest(destPath))
.pipe(gulp.dest('css'));
});
};

View File

@@ -1,20 +1,23 @@
const eslint = require('gulp-eslint');
const uglify = require('gulp-uglify');
const eslint = require('gulp-eslint');
const uglify = require('gulp-uglify');
const jsPath = '_scripts/*.js';
const jsPath = '_scripts/*.js';
const destPath = '_site/js';
module.exports = gulp => {
gulp.task('scripts', () => {
return gulp.src(jsPath)
.pipe(eslint({
useEslintrc: true
}))
.pipe(eslint.format())
// .pipe(uglify())
.pipe(gulp.dest(destPath))
.pipe(gulp.dest('js'));
return (
gulp
.src(jsPath)
.pipe(
eslint({
useEslintrc: true,
})
)
.pipe(eslint.format())
// .pipe(uglify())
.pipe(gulp.dest(destPath))
.pipe(gulp.dest('js'))
);
});
};