-
Notifications
You must be signed in to change notification settings - Fork 1
/
.eleventy.js
59 lines (47 loc) · 1.79 KB
/
.eleventy.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
const htmlmin = require('html-minifier')
const posthtml = require('posthtml')
const minifyClassnames = require('posthtml-minify-classnames')
const pluginInlineCss = require('@navillus/eleventy-plugin-inline-css')
module.exports = function ( eleventyConfig ) {
// Copy static files
eleventyConfig.addPassthroughCopy({
"static": "/"
})
eleventyConfig.addPlugin(pluginInlineCss, {
input: 'static', // look for all stylesheets relative to `./src/assets`
cleanCss: false, // disable clean-css
purgeCss: true
// {
// defaultExtractor: content => content.match(/[\w-/:]+(?<!:)/g) || [] // custom CSS extractor used for PurgeCSS
// }
})
eleventyConfig.addTransform('htmlmin', async function(content, outputPath) {
// Eleventy 1.0+: use this.inputPath and this.outputPath instead
if( outputPath.endsWith('.html') ) {
const { html: htmlWithMiniClassnames } = await posthtml()
.use(minifyClassnames())
.process( content )
// https://github.com/kangax/html-minifier#options-quick-reference
let minified = htmlmin.minify( htmlWithMiniClassnames , {
useShortDoctype: true,
removeComments: true,
collapseWhitespace: true,
collapseInlineTagWhitespace: true,
minifyCSS: true
})
return minified
}
return content;
})
// console.log('eleventyConfig', eleventyConfig)
return {
dir: {
input: 'src',
output: 'dist',
// jsDataFileSuffix: '.json',
// Relative to input directory.
// data: '../static',
// layouts: '../layouts-eleventy'
}
}
}