-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eleventy.js
31 lines (24 loc) · 1.05 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
import CleanCSS from "clean-css";
export default function (eleventyConfig) {
// Output directory: _site
// Copy `images/` to `_site/images`
eleventyConfig.addPassthroughCopy('images');
// copy other needed files
eleventyConfig.addPassthroughCopy('favicon.ico');
eleventyConfig.addPassthroughCopy('manifest.json');
eleventyConfig.addFilter("cssmin", function (code) {
const output = new CleanCSS({
level: {
2: {
// https://www.npmjs.com/package/clean-css#level-2-optimizations
all: true, // sets all level 1 and 2 optimization values to `true`
}
}
}).minify(code);
console.log('******css min perf*******');
console.log('original size', output.stats.originalSize); // original content size after import inlining
console.log('minified size', output.stats.minifiedSize); // optimized content size
console.log('efficiency', output.stats.efficiency); // `(originalSize - minifiedSize) / originalSize`, e.g. 0.25 if size is reduced from 100 bytes to 75 bytes
return output.styles;
});
};