2017-06-10 20:35:01 +00:00
|
|
|
const gulp = require('gulp');
|
|
|
|
const exec = require('child_process').exec;
|
|
|
|
const rimraf = require('rimraf');
|
2017-02-26 21:24:53 +00:00
|
|
|
|
2017-06-10 20:35:01 +00:00
|
|
|
const ghPages = require('gulp-gh-pages');
|
2017-02-26 21:24:53 +00:00
|
|
|
|
2017-06-10 20:35:01 +00:00
|
|
|
const md5 = require("gulp-md5-plus");
|
|
|
|
const postcss = require('gulp-postcss');
|
|
|
|
const cssImport = require('postcss-import');
|
|
|
|
const cssnext = require('postcss-cssnext');
|
|
|
|
const cleanCSS = require('gulp-clean-css');
|
2017-02-26 21:24:53 +00:00
|
|
|
|
2017-06-10 20:35:01 +00:00
|
|
|
const imageResize = require('gulp-image-resize');
|
2017-02-26 21:24:53 +00:00
|
|
|
|
2017-06-10 20:35:01 +00:00
|
|
|
const htmlmin = require('gulp-htmlmin');
|
2017-02-26 21:24:53 +00:00
|
|
|
|
|
|
|
const distPath = './site/public';
|
|
|
|
const cname = 'citra-emu.org';
|
|
|
|
const deployOptions = {
|
|
|
|
remoteUrl: "git@github.com:CitraBotWeb/CitraBotWeb.github.io.git",
|
|
|
|
branch: "master"
|
|
|
|
};
|
|
|
|
|
|
|
|
gulp.task("default", ['html']);
|
|
|
|
|
|
|
|
gulp.task('setup', function(cb) {
|
|
|
|
process.env.HUGO_ENV = 'PRD';
|
|
|
|
process.env.GULP = 'true';
|
|
|
|
rimraf(`${distPath}`, cb);
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('hugo', ['setup'], function (cb) {
|
|
|
|
exec('hugo -s ./site/ -v', function (err, stdout, stderr) {
|
|
|
|
console.log(stdout);
|
|
|
|
console.log(stderr);
|
|
|
|
cb(err);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task("css", ['hugo'], () => (
|
|
|
|
gulp.src(`${distPath}/css/**/*.css`, {base: './'})
|
|
|
|
.pipe(postcss([cssnext(), cssImport({from: `${distPath}/css/main.css`})]))
|
|
|
|
.pipe(cleanCSS())
|
|
|
|
.pipe(md5(10, `${distPath}/**/*.html`))
|
|
|
|
.pipe(gulp.dest('./'))
|
|
|
|
));
|
|
|
|
|
|
|
|
gulp.task('images', ['hugo'], () => (
|
|
|
|
gulp.src(`${distPath}/images/*`, {base: './'})
|
|
|
|
.pipe(gulp.dest('./')),
|
|
|
|
gulp.src(`${distPath}/images/jumbotron/*`, {base: './'})
|
2017-06-10 20:35:01 +00:00
|
|
|
.pipe(imageResize({ width: 786, height: 471, crop: true }))
|
2017-02-26 21:24:53 +00:00
|
|
|
.pipe(gulp.dest('./')),
|
|
|
|
gulp.src(`${distPath}/images/banners/*`, {base: './'})
|
2017-06-10 20:35:01 +00:00
|
|
|
.pipe(imageResize({ width: 824, height: 306, crop: false }))
|
2017-06-04 18:30:07 +00:00
|
|
|
.pipe(gulp.dest('./')),
|
2017-06-04 18:28:06 +00:00
|
|
|
gulp.src(`${distPath}/images/game/boxart/*`, {base: './'})
|
2017-06-10 20:35:01 +00:00
|
|
|
.pipe(imageResize({ width: 328, height: 300, crop: true }))
|
2017-06-04 18:30:07 +00:00
|
|
|
.pipe(gulp.dest('./')),
|
2017-06-04 18:28:06 +00:00
|
|
|
gulp.src(`${distPath}/images/game/icons/*`, {base: './'})
|
2017-06-10 20:35:01 +00:00
|
|
|
.pipe(imageResize({ width: 48, height: 48, crop: true }))
|
2017-06-04 18:28:06 +00:00
|
|
|
.pipe(gulp.dest('./'))
|
2017-02-26 21:24:53 +00:00
|
|
|
));
|
|
|
|
|
|
|
|
gulp.task('html', ['hugo', 'css', 'images'], () => (
|
|
|
|
gulp.src(`${distPath}/**/*.html`, {base: './'})
|
|
|
|
.pipe(htmlmin({collapseWhitespace: true}))
|
|
|
|
.pipe(gulp.dest('./'))
|
|
|
|
));
|
|
|
|
|
|
|
|
gulp.task('deploy', ['hugo', 'css', 'images', 'html'], () => {
|
|
|
|
require('fs').writeFileSync(`${distPath}/CNAME`, `${cname}`);
|
2017-02-27 02:24:32 +00:00
|
|
|
require('fs').writeFileSync(`${distPath}/robots.txt`, `Sitemap: https://${cname}/sitemap.xml\n\nUser-agent: *`);
|
2017-02-26 21:24:53 +00:00
|
|
|
return gulp.src(`${distPath}/**/*`).pipe(ghPages(deployOptions));
|
|
|
|
});
|