28 lines
816 B
JavaScript
28 lines
816 B
JavaScript
|
const htmlmin = require("html-minifier");
|
||
|
const CleanCSS = require("clean-css");
|
||
|
|
||
|
module.exports = function (eleventyConfig) {
|
||
|
eleventyConfig.addPassthroughCopy("publi");
|
||
|
eleventyConfig.addFilter("cssmin", function (code) {
|
||
|
return new CleanCSS({}).minify(code).styles;
|
||
|
});
|
||
|
eleventyConfig.addTransform("htmlmin", function (content, outputPath) {
|
||
|
if (outputPath.endsWith(".html")) {
|
||
|
return htmlmin.minify(content, {
|
||
|
useShortDoctype: true,
|
||
|
removeComments: true,
|
||
|
collapseWhitespace: true,
|
||
|
minifyJS: true,
|
||
|
minifyCSS: true,
|
||
|
});
|
||
|
}
|
||
|
|
||
|
return content;
|
||
|
});
|
||
|
eleventyConfig.addTransform("cssmin", function (content, outputPath) {
|
||
|
if (outputPath.endsWith(".css")) {
|
||
|
return new CleanCSS({}).minify(content);
|
||
|
}
|
||
|
return content;
|
||
|
});
|
||
|
};
|