Development

Jekyll NPM Build Script

Jekyll build process example using npm scripts to build assets/js/main.min.js. The scripts copies vendor sass partials to _sass/vendor/ directory and vendor javascripts to assets/js/vendor/ directory, concatenates and minifies js files and watches for changes.

  1. Install Node.js
  2. Install all of the dependencies by running npm install in theme root directory, this will install all SCSS and JS dependencies, compress and concatenate JS scripts into main.min.js.
  3. Availabele commands:
  • npm install
  • npm run watch
{
  "name": "jekyll-theme-plus",
  "version": "1.0.0",
  "description": "Advanced Jekyll theme",
  "repository": {
    "type": "git",
    "url": "https://github.com/ivanchromjak/jekyll-theme-plus.git"
  },
  "author": "Ivan Chromjak",
  "license": "MIT",
  "bugs": {
    "url": "https://github.com/ivanchromjak/jekyll-theme-plus/issues"
  },
  "homepage": "https://plus.jekyll.plus",
  "dependencies": {
    "simple-jekyll-search": "^1.5.0",
    "system-font-css": "^2.0.1",
    "uikit": "^3.0.0-beta.31"
  },
  "devDependencies": {
    "cpx": "^1.5.0",
    "jshint": "^2.9.5",
    "ncp": "latest",
    "onchange": "^3.3.0",
    "uglify-js": "^3.2.1"
  },
  "scripts": {
    "copy:sass": "ncp node_modules/uikit/src/scss/ _sass/vendor/uikit/ && ncp node_modules/system-font-css/ _sass/vendor/system-font-css/",
    "copy:js": "cpx \"node_modules/uikit/dist/js/uikit.js\" assets/js/vendor/ && cpx \"node_modules/uikit/dist/js/uikit-icons.js\" assets/js/vendor/ && cpx \"node_modules/simple-jekyll-search/dest/simple-jekyll-search.js\" assets/js/vendor/",
    "lint": "jshint assets/js/_main.js",
    "uglify": "uglifyjs assets/js/vendor/uikit.js assets/js/vendor/uikit-icons.js assets/js/vendor/simple-jekyll-search.js assets/js/_main.js -m -c -o assets/js/main.min.js",
    "build": "npm run lint && npm run uglify",
    "watch": "onchange \"assets/js/**/*.js\" -e \"assets/js/main.min.js\" -- npm run build",
    "postinstall": "npm run copy:sass && npm run copy:js && npm run build"
  }
}

Related Posts

Hugo

The Ultimate Guide to Choosing and Customizing Hugo Themes

Unleashing the power of Hugo static generator for your website.

Hugo

Unlock the Potential of Your Hugo Blog

Delve deeper into the world of Hugo blog themes and how to get started fast.