87 lines
2.7 KiB
JavaScript
87 lines
2.7 KiB
JavaScript
import path from "node:path";
|
|
|
|
import { HtmlBasePlugin as plugin_html } from "@11ty/eleventy";
|
|
import { default as plugin_navigation } from "@11ty/eleventy-navigation";
|
|
import { default as plugin_ejs } from "@11ty/eleventy-plugin-ejs";
|
|
import { default as plugin_less } from "./plugins/less.js";
|
|
import { default as plugin_minify_html } from "./plugins/minify-html.js";
|
|
import { default as plugin_minify_js } from "./plugins/minify-js.js";
|
|
import { default as plugin_minify_css } from "./plugins/minify-css.js";
|
|
|
|
export default async function (eleventyConfig) {
|
|
// Watch Targets
|
|
eleventyConfig.addWatchTarget(path.format(path.parse("./data/**/*")));
|
|
eleventyConfig.addWatchTarget(path.format(path.parse("./styles/**/*")));
|
|
eleventyConfig.addWatchTarget(path.format(path.parse("./assets/**/*")));
|
|
|
|
// Passthroughs
|
|
eleventyConfig.addPassthroughCopy({
|
|
[`${path.format(path.parse("./assets"))}`]: path.format(path.parse("/assets")),
|
|
});
|
|
|
|
// Plugins
|
|
eleventyConfig.addPlugin(plugin_html);
|
|
eleventyConfig.addPlugin(plugin_navigation);
|
|
eleventyConfig.addPlugin(plugin_ejs);
|
|
eleventyConfig.addPlugin(plugin_less);
|
|
eleventyConfig.addPlugin(plugin_minify_html, { minifyOptions: {
|
|
caseSensitive: true,
|
|
collapseBooleanAttributes: true,
|
|
collapseInlineTagWhitespace: true,
|
|
collapseWhitespace: true,
|
|
conservativeCollapse: true,
|
|
decodeEntities: true,
|
|
html5: true,
|
|
keepClosingSlash: true,
|
|
minifyCSS: true,
|
|
minifyJS: true,
|
|
minifyURLs: true,
|
|
preserveLineBreaks: false,
|
|
quoteCharacter: "\"",
|
|
removeComments: true,
|
|
removeScriptTypeAttributes: true,
|
|
removeStyleLinkTypeAttributes: true,
|
|
sortAttributes: true,
|
|
sortClassName: false, // Breaks CSS selector order!
|
|
useShortDoctype: true }});
|
|
eleventyConfig.addPlugin(plugin_minify_js, { minifyOptions: {
|
|
mangle: false,
|
|
sourceMap: { url: "inline" }}
|
|
});
|
|
eleventyConfig.addPlugin(plugin_minify_css, { minifyOptions: {
|
|
level: 2,
|
|
inline: false,
|
|
sourceMap: true,
|
|
sourceMapInlineSources: true,
|
|
}});
|
|
|
|
// Liquid configuration
|
|
eleventyConfig.setLiquidParameterParsing("builtin");
|
|
|
|
// Old Page Redirection
|
|
eleventyConfig.addCollection("redirects", function(pageApi) {
|
|
let redirects = [];
|
|
|
|
for(let page of pageApi.getAll()) {
|
|
let aliases = page.data?.aliases;
|
|
for (let idx in aliases) {
|
|
console.log(`Aliasing '${aliases[idx]}' to '${page.data.page.url}'`);
|
|
redirects.push([`/${aliases[idx]}`, page]);
|
|
}
|
|
}
|
|
|
|
return redirects;
|
|
})
|
|
};
|
|
|
|
export const config = {
|
|
"dir": {
|
|
"output": "build",
|
|
"input": "source",
|
|
"data": path.format(path.parse("../data")),
|
|
"layouts": path.format(path.parse("../layouts")),
|
|
"includes": path.format(path.parse("../includes")),
|
|
"styles": path.format(path.parse("../styles")),
|
|
},
|
|
}
|