Skip to content

Commit

Permalink
Merge pull request #20 from chriskyfung/chore/update-npm-packages
Browse files Browse the repository at this point in the history
  • Loading branch information
chriskyfung authored Sep 30, 2024
2 parents 1acbe9f + 22766ba commit 0094a9b
Show file tree
Hide file tree
Showing 3 changed files with 987 additions and 4,007 deletions.
22 changes: 9 additions & 13 deletions gulpfile.js → gulpfile.mjs
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
const {src, dest, watch, series, parallel} = require('gulp');
const htmlmin = require('gulp-htmlmin');
const minifyInline = require('gulp-minify-inline');
const processIfModified = require('gulp-process-if-modified');
import { src, dest, watch, series, parallel } from 'gulp';
import htmlmin from 'gulp-html-minifier-terser';
import gulpAmpValidator from 'gulp-amphtml-validator';

const through2 = require('through2');
import through2 from 'through2';
import amphtmlValidator from 'amphtml-validator';
import AmpOptimizer from '@ampproject/toolbox-optimizer';

const AmpOptimizer = require('@ampproject/toolbox-optimizer');
const ampOptimizer = AmpOptimizer.create();
const gulpAmpValidator = require('gulp-amphtml-validator');
const amphtmlValidator = require('amphtml-validator');

function build(cb) {
return src('./_site/**/*.html')
.pipe(processIfModified())
.pipe(
through2.obj(async (file, _, cb) => {
if (file.isBuffer()) {
const date = new Date();
console.log(`[\x1b[90m${date.toLocaleTimeString('it-IT')}\x1b[0m] Running AMP Optimizer on ${file.path}`);
const optimizedHtml = await ampOptimizer.transformHtml(
file.contents.toString()
);
Expand All @@ -25,7 +24,6 @@ function build(cb) {
})
)
.pipe(htmlmin({ collapseWhitespace: false }))
.pipe(minifyInline())
.pipe(dest('./_site/'));
}

Expand Down Expand Up @@ -65,6 +63,4 @@ function validate() {
);
}

exports.build = build;
exports.test = test;
exports.validate = validate;
export { build, test, validate };
Loading

0 comments on commit 0094a9b

Please sign in to comment.