Type

Config

From mothwing ยท src/config.js:11

What a site's mothwing.config.js default exports. Only domain is needed. Paths are relative to src unless they say otherwise. The extras (minify to activeLinks) are off until asked for: true turns one on as it comes, an object with its own settings.

Properties

domainstring"example.com", for the canonical URLs, sitemaps and CNAME
srcoptionalstringThe source folder, relative to the config. "src"
outoptionalstringThe build folder, relative to the config. "dist"
pagesoptionalstringThe pages folder. "pages"
partialsoptionalstringThe partials folder, left out of the build. <x-html> takes a partial from anywhere in src, this is only the folder that isn't copied. "partials"
dataoptionalstringThe data folder, its files are in every page by their name: projects.json -> {{ projects }}. Left out of the build. "data"
notFoundoptionalstringThe 404 page, in the pages folder. Kept in the build's root, out of the sitemap. "404.html"
jsoptionalJsConfigThe JS to bundle
sassoptionalRecord<string, string>Sass to compile, source to output: { "scss/index.scss": "css/index.css" }. Needs sass installed
excludeoptionalstring[]Folders left out of the build, on top of pages, partials and data: ["js", "scss"]
rerenderoptionalstring[]Folders and files the pages read with fs, whose changes render every page again in dev. They can be outside src, "../README.md", and are watched too, Sass in them builds the CSS first. What the pages import, include or use from the data folder is followed on its own
seooptionalSeoConfigFor <x-seo>
minifyoptionalbooleanMinify the HTML of production builds: comments and the whitespace that doesn't show are taken out, and esbuild minifies the inline scripts and styles. The tags and their attributes stay as written
cspoptionalboolean | Record<string, string>A Content-Security-Policy <meta> that allows only the site's own files, and its inline scripts by their hash. An object sets directives over the defaults: { "style-src": "'self' 'unsafe-inline'" }
sitemapoptionalboolean | SitemapConfigsitemap.xml with every page, each dated by the last git commit to its files
robotsoptionalboolean | RobotsConfigrobots.txt, allowing every crawler and pointing at the sitemap
cnameoptionalbooleanA CNAME file with the domain, for GitHub Pages
activeLinksoptionalboolean | ActiveLinkaria-current="page" on links to the page they're on, "true" on links to its section
tagsoptionalRecord<string, TagFunction>Your own tags: { "x-name": ({ attrs }) => "<b>html</b>" }
transformsoptionalTransform[]Run on every page's HTML once its placeholders are filled
afteroptionalHook[]Run once the pages are written
esbuildoptionalBuildOptionsesbuild options for every bundle, over mothwing's