A starter boilerplate powered by 11ty, Sanity, Gulp, Tailwind CSS, rollup.js, Alpine.js and Taxi.js.
1. Install Node 16.17.1 LTS: https://nodejs.org/
$ npm i -g yarn
$ yarn
In config.js, update Sanity options and environment URLs for project compilation.
$ yarn dev
$ yarn stage
$ yarn prod
- Features Gulp as the build pipeline that renders HTML, compiles styles and scripts, and optimizes assets.
- Data is coming from the Sanity Cloud API. This pairs perfectly with the ByMattLee Sanity Studio Starter
- Spins up a local development environment through Browsersync
- Browser reload when NJK, JS, image, SVG or asset files are updated
- Styles are injected when SCSS files are updated
- Features 11ty as the static site generator
- Markup is minified in staging and production environments
- Site data can be set in
src/site/_data - Pages in
src/sitewill be compiled todist src/site/_includes/layouts/base.njkserves as the base template for the sitesrc/site/_includes/partialscontains site partials and components that are reused across the site (modular HTML)
- Features Tailwind CSS, a utility-first framework
- Includes linter (Stylelint), autoprefixer, minification and sourcemap creation
- SCSS files are located in
src/assets/scss main.scssinsrc/assets/scssserves as the base that includes the other dependent SASS filesmain.scssgets compiled todist/assets/css/main.min.css.stylelintrccontains the settings for Stylelint- Info about class namespacing can be found in
src/assets/scss/main.scss - Unused CSS (PurgeCSS) will be removed in staging and production builds
- Features rollup.js as the module bundler
- Includes linting (ESLint), concatenation, minification and sourcemap creation
- Includes Taxi.js for seamless page transitions
- Includes a custom framework for reuseable content animations
- Includes Alpine.js for declarative DOM manipulation
main.jsinsrc/assets/jsserves as the main JS file that includes and runs all components and will be compiled todist/assets/js/main.min.js- All local components should be placed in
src/assets/js/components - All vendor JS can be manually added to
src/assets/js/vendorsif not found on Yarn .eslintrccontains the settings for ESLint
- Place all unoptimized images in the
src/assets/imagesdirectory - They will then be optimized and placed in
dist/assets/images - Responsive images will be generated at the following widths (if larger): 200w, 400w, 600w, 800w, 1000w, 1200w, 1400w, 1600w, 1800w
- Use
imageSrcshortcode to render responsivesrcsetin markup
- Place all SVG files in the
src/assets/svgdirectory - They will then be optimized and added to a sprite at
dist/assets/svg/sprite.svg
- All assets (fonts, videos, swfs, etc) under
src/assetswill be copied todist/assetson build
- Generates a sitemap based on the HTML files in
dist
- Generates a robots.txt file
- Configuration can be found in
src/site/robots.njk
- All Tailwind settings can be found in
./tailwind.config.js - Most styles should be written as utility classes in the template markup but custom SCSS can be used for unique properties and/or magic numbers
- Utilize the
@applydirective when writing custom SCSS for efficiency:
svg {
@apply u-inline-block u-fill-current;
}- Tailwind settings can be accessed with the
theme()function:
.button {
animation-duration: theme('transitionDuration.normal');
}- Media queries can be used with the shorthand
screen()function:
.button {
margin-right: 2.8rem;
@screen sm {
margin-right: 4.2rem;
}
}- Matt Lee -
@bymattleeon most platforms - Visit my website at bymattlee.com
