-
npm iShipped to browsers ->
dependencies. Used only dev-time ->devDependencies. -
npm startto start dev mode
- MDX
- Custom build pipeline with CLI tools, aiming for simplicity
The aim was a build pipeline that is a bunch of CLI commands. Lack of hot reloading makes the iteration somewhat slow (5-10s after each file change).
Production build with approximate times:
-
(11.8s)
Render pagesstage. Generates entrypoint files for each page-
For each "regular" page under src/pages
-
index.htmlthe main HTML for the page. -
hydrate.tsxthe script thatReact.hydrates the given page when loaded at frontendsrc/pages/_exports.ts has information that tells which React component file we should import (e.g. Index.tsx).
The static parts of the page work just well without this script.
-
-
For each MDX "post" page under posts
-
index.htmlsame as above -
<postName>-post-hydrate.tsxsame as above, except it importsPostPagecomponent that is also generated dynamically -
<postName>-post.tsxwhich is is responsible for hydrating the MDX contentNote that hydrate is not the same as
React.hydrate. Instead it uses next-mdx-remote's hydrate. The flow is:- Node.js process renders MDX content to HTML string, and also transpiles the MDX content into a React component code. The code is quite short and well commented: https://github.com/hashicorp/next-mdx-remote/blob/main/render-to-string.js
- Frontend takes in the rendered HTML, and babel transpiled component code and starts the dynamic components in frontend. See next-mdx-remote/blob/main/hydrate.js)
-
compiledSource.txtThe MDX component source code transpiled with Babel, mentioned aboveWe need to be able to transfer the text contents exactly as-is to the frontend. A good way to do this was using a rollup text plugin, which is used in the next steps.
.txtextension is used just to make configuring the rollup plugin easier.It used to be just a simple regex replacement in
<postName>-post.tsxfile, but it broke with line breaks. -
renderedOutput.txtThe HTML content of the MDX blog post.
-
-
site-data.jsonfile that contains all metadata of the site, including pages -
prism-theme.csscontains dynamically rendered Prism theme CSS, based on tailwind.config.js
-
-
(11.98s)
Bundle modulesstage. Bundles the dynamically created files for each page to one JS bundle per pageRollup seemed like a good fit for this type of setup where we want absolute control over the build. Rollup requires quite precise configuration, the following plugins are used:
replacemodule to e.g. take either dev or prod version of ReactnodeResolvemodule to make rollup followrequire('react')calls into node_modules and include them into the bundlestringto include the text files in JS codecommonjsjsonto be able to import json file (site data)typescript
-
(9.9s)
CSSstage. Generate distributable CSS file with PostCSSTailwind is used as the main CSS framework.
-
Static filesstage. Copies everything from public/ to the root of output -
RSSstage. Generates RSS feed of the content. -
HTMLstage. Lints accessibility and minifies the HTML. -
Lighthousestage. Builds a Lighthouse CI report which is deployed to https://kimmo.blog/perf. It is being ran in Netlify's slow build machine, so performance shows lower than it should.
- Light / dark mode
- Initial page load vs state update
- JS disabled
-
Grammar check:
npm run mdxToText -- posts/2-making-diy-gatsby-part-i.mdx | pbcopyand copy to Google Docs. -
Date?
-
Title changed?
- Update slug
- Add Netlify redirect. ID number is meant to be permanent, while the slug
- Update cover image
- Test with
squint http://localhost:8080 https://kimmo.blog
See https://presentic.co for introduction.
When exporting presentics from Figma, use "Include id" option. After the export, set #viewport rectangles to have stroke-width="0" from the SVG output. Presentic needs them for slides.
Convert .mov files to .mp4:
ffmpeg -i shuffling1.mov -q:v 0 shuffling1.mp4
The code is MIT licensed. MIT license does not apply to any other content such as images and text content for the blog.