chore: restore transforms
This commit is contained in:
parent
909008d068
commit
6e366c0fe5
1 changed files with 24 additions and 0 deletions
24
.eleventy.js
24
.eleventy.js
|
@ -4,6 +4,7 @@ import lightningCSS from '@11tyrocks/eleventy-plugin-lightningcss'
|
||||||
import markdownIt from 'markdown-it'
|
import markdownIt from 'markdown-it'
|
||||||
import markdownItAnchor from 'markdown-it-anchor'
|
import markdownItAnchor from 'markdown-it-anchor'
|
||||||
import markdownItFootnote from 'markdown-it-footnote'
|
import markdownItFootnote from 'markdown-it-footnote'
|
||||||
|
import htmlmin from 'html-minifier-terser'
|
||||||
import filters from './config/filters/index.js'
|
import filters from './config/filters/index.js'
|
||||||
import { minifyJsComponents } from './config/events/index.js'
|
import { minifyJsComponents } from './config/events/index.js'
|
||||||
import { allContent, popularPosts, searchIndex } from './config/collections/index.js'
|
import { allContent, popularPosts, searchIndex } from './config/collections/index.js'
|
||||||
|
@ -83,6 +84,29 @@ export default async function (eleventyConfig) {
|
||||||
eleventyConfig.addShortcode('appVersion', () => appVersion)
|
eleventyConfig.addShortcode('appVersion', () => appVersion)
|
||||||
eleventyConfig.addShortcode('currentYear', () => DateTime.now().year)
|
eleventyConfig.addShortcode('currentYear', () => DateTime.now().year)
|
||||||
|
|
||||||
|
// transforms
|
||||||
|
eleventyConfig.addTransform('html-minify', (content, path) => {
|
||||||
|
if (path && path.endsWith('.html')) {
|
||||||
|
return htmlmin.minify(content, {
|
||||||
|
collapseBooleanAttributes: true,
|
||||||
|
collapseWhitespace: true,
|
||||||
|
decodeEntities: true,
|
||||||
|
includeAutoGeneratedTags: false,
|
||||||
|
minifyCSS: true,
|
||||||
|
minifyJS: true,
|
||||||
|
minifyURLs: true,
|
||||||
|
noNewlinesBeforeTagClose: true,
|
||||||
|
quoteCharacter: '"',
|
||||||
|
removeComments: true,
|
||||||
|
sortAttributes: true,
|
||||||
|
sortClassName: true,
|
||||||
|
useShortDoctype: true,
|
||||||
|
processScripts: ['application/ld+json'], // minify JSON-LD scripts
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return content
|
||||||
|
})
|
||||||
|
|
||||||
// events
|
// events
|
||||||
eleventyConfig.on('afterBuild', minifyJsComponents)
|
eleventyConfig.on('afterBuild', minifyJsComponents)
|
||||||
|
|
||||||
|
|
Reference in a new issue