Note that this repo is only concerned with demonstrating an asset pipeline and not considered a full starter. Do with it as you wish, but keep in mind that everything here is designed for our internal workflow.
We use a Changelog on all of our projects. Please see that file for updates.
require
)This set up utilizes Parcel for Javascript and open source font processing, Hugo Pipes + PostCSS for CSS processing, and npm-run-all
to run Parcel and Hugo in parallel (see note below). We use the Yarn package manager, but you can use NPM if you like.
This asset pipeline is a shift for us from using Webpack to process JS/Fonts/CSS. Parcel is a bundler like Webpack, yet as a tradeoff for slightly less flexibility it has a smaller configuration and file footprint and builds faster; in fact, there is no Parcel configuration file. The shift to using Hugo to build CSS allows Hugo sites to be developed outside of an external build process. There are drawbacks to this approach, as outlined below.
package.json
include loading of environment variables with cross-env
which is optional for some systems (not windows) and can safely be removed. Just replace cross-env NODE_ENV=development
with NODE_ENV=development
assets/output/index.js
.fileExists "./assets/output/index.js
Hugo creates a hash of that file from layouts/_head/scripts.html
.public/output/index.min.[hash].js
.assets/css/styles.css
with assets/postcss.config.js
, utilizing Imports, TailwindCSS, Autoprefixer, and PurgeCSS.NODE_ENV=development
is present in the build command, PostCSS will NOT process the file through PurgeCSS.public/css/styles.min.[hash].css
.assets/css/styles.css
with assets/postcss.config.js
, utilizing Imports, TailwindCSS, Autoprefixer, and PurgeCSS.NODE_ENV=development
is present in the build command, PostCSS will NOT process the file through PurgeCSS.assets/output/index.[hash].css
.assets/output/index.css
and also puts the font files, hashed, in the same directory.fileExists "./assets/output/index.css
Hugo creates the prefetch links from layouts/_head/stylesheets.html
.public/output/index.min.[hash].css
and public/output/font-name.[hash].woff[2]
.assets/index.js
.layouts/_head/stylesheets.html
to use Hugo (see comments in that file).