Base library for m-ld.io web projects.
Template project setup is in the template
folder.
The build
package contains the build-time dev dependencies and utilities.
The runtime
package contains the runtime dependencies and utilities.
For website delivery and serverless lambdas.
The team account is https://vercel.com/m-ld.
Setup:
- Install the vercel CLI.
- Root
vercel.json
has build and lambda environment configuration for CD builds. - For local development:
- root file
.env.build
has build configuration. Note the emptyNPM_TOKEN
in the template file causes npm to use your local environment's npm token. - root file
.env
has lambda configuration.
- root file
- For lambdas, create a source folder
api
per Vercel convention, and use the runtime package exports to create path functions.
For static site generation.
Setup:
- Root
.eleventy.js
exports the Eleventy configuration function.
For browser feature detection.
Setup:
src/modernizr-custom.js
contains a downloaded custom Modernizr script. Note that this location is included by the default Eleventy configuration.
For a CSS framework.
See template/src/main.scss
.
For icons.
See template/src/main.scss
.
For remote logging.
Setup:
- Ensure that
LOGZ_KEY
is available in.env
andvercel.json
(env
key). - Use
loglevel
for runtime logging. - Import from
@m-ld/io-web-runtime/dist/client
. - Call
configureLogging
before using log methods. - Call
setLogToken
when the session token is renewed.
For bot detection.
Setup:
- Import from
@m-ld/io-web-runtime/dist/client
. await Grecaptcha.ready
before making any requests to a reCAPTCHA-authorised lambda.- Call
await Grecaptcha.execute('<action>')
to get a token.
For script packaging.
Setup:
@m-ld/io-web-build
has the functionrenderTs
which can be used in a11ty.js
template to compile and package a root TypeScript file.
For scripts and serverless lambdas.
See template/tsconfig.template.json
(named to avoid IDE misunderstandings).