feat: optimize component js post-build + new youtube component
This commit is contained in:
parent
e4bde98686
commit
ecb23daebf
20 changed files with 59 additions and 175 deletions
|
@ -1,7 +1,8 @@
|
|||
import fs from 'fs'
|
||||
import Image from '@11ty/eleventy-img'
|
||||
import { minify } from 'terser'
|
||||
|
||||
export const svgToJpeg = function () {
|
||||
export const svgToJpeg = () => {
|
||||
const socialPreviewImagesDir = '_site/assets/img/social-preview/'
|
||||
fs.readdir(socialPreviewImagesDir, (err, files) => {
|
||||
if (!!files && files.length > 0) {
|
||||
|
@ -23,3 +24,17 @@ export const svgToJpeg = function () {
|
|||
}
|
||||
})
|
||||
}
|
||||
|
||||
export const minifyJsComponents = async () => {
|
||||
const jsComponentsDir = '_site/assets/scripts/components';
|
||||
const files = fs.readdirSync(jsComponentsDir);
|
||||
for (const fileName of files) {
|
||||
if (fileName.endsWith('.js')) {
|
||||
const filePath = `${jsComponentsDir}/${fileName}`;
|
||||
const minified = await minify(fs.readFileSync(filePath, 'utf8'));
|
||||
fs.writeFileSync(filePath, minified.code);
|
||||
} else {
|
||||
console.log('⚠ No js components found')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue