Skip to content
This repository has been archived by the owner on Sep 15, 2023. It is now read-only.
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: vigetlabs/blendid
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: blendid5
Choose a base ref
...
head repository: vigetlabs/blendid
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Can’t automatically merge. Don’t worry, you can still create the pull request.

Commits on Mar 11, 2019

  1. chore(dependencies): non-breaking dependency updates from npm audit...

    Updates
    
    - browser-sync
    - babel-core
    - gulp-nunjucks-render
    - lodash
    - debug
    
    and regenerates the Yarn lockfile.
    
    Drops 490 vulnerabilities (266 low, 207 moderate, 15 high, 2 critical)
    to 15 vulnerabilities (7 low, 2 moderate, 4 high, 2 critical).
    
    Actions run:
    
    npm install --package-lock-only
    npm audit
    npm install browser-sync@2.26.3
    npm install babel-core@6.26.3
    npm install gulp-nunjucks-render@2.2.2
    npm install lodash@4.17.11
    npm update lodash --depth 10
    npm update debug --depth 9
    rm yarn.lock
    yarn import
    
    Sticking with yarn.lock rather than switch wholesale to package-lock.json
    to avoid the "verbose stack TypeError: Cannot read property 'match' of undefined"
    npm-shrinkwrap error.
    olets committed Mar 11, 2019
    Copy the full SHA
    74d3353 View commit details
  2. chore(dependencies): babel-present-env replaces babel-preset-es2015...

    Actions run:
    
    npm install babel-preset-env
    npm uninstall babel-preset-es2015
    rm yarn.lock
    yarn import
    olets committed Mar 11, 2019
    Copy the full SHA
    75d22c0 View commit details
  3. chore(watch): gulp's watch replaces gulp-watch...

    Actions run:
    
    npm uninstall gulp-watch
    olets committed Mar 11, 2019
    Copy the full SHA
    159bc7d View commit details
  4. Copy the full SHA
    2029d11 View commit details
  5. chore(dependencies): make all safe dependency updates...

    Upgrades:
    
    - ansi-colors
    - del
    - es6-promise
    - fancy-log
    - gulp-autoprefixer
    - gulp-changed
    - gulp-cssnano
    - gulp-data
    - gulp-htmlmin
    - gulp-notify
    - gulp-rename
    - gulp-replace
    - gulp-rev
    - gulp-rev-replace
    - gulp-sass
    - gulp-sequence
    - gulp-sizereport
    - gulp-sourcemaps
    - gulp-svgstore
    - node-sass-glob-importer
    - plugin-error
    - require-dir
    
    Actions run:
    
    > yarn upgrade --latest
    > yarn add babel-loader@"^7.1.1"
    > yarn add gulp@3.9.1
    > yarn add webpack@"^3.4.1"
    > yarn add webpack-dev-middleware@"^1.12.0"
    > yarn add webpack-hot-middleware@"^2.18.2"
    > yarn add chai@"^3.5.0" -D
    olets committed Mar 11, 2019
    Copy the full SHA
    e16c07d View commit details
  6. Copy the full SHA
    b248b6b View commit details
  7. Copy the full SHA
    4bfa3f5 View commit details
  8. Copy the full SHA
    818fb63 View commit details
  9. Copy the full SHA
    791a334 View commit details
  10. Copy the full SHA
    0761a05 View commit details

Commits on Mar 21, 2019

  1. Copy the full SHA
    bd22e26 View commit details

Commits on Mar 22, 2019

  1. Copy the full SHA
    1abc5d2 View commit details
  2. Copy the full SHA
    983e160 View commit details
  3. chore(bump): version 4.5.0

    olets committed Mar 22, 2019
    Copy the full SHA
    f914316 View commit details

Commits on Jun 25, 2019

  1. fix(ci testing): use new way to run xvfb on Travis CI...

    In April 2019, Travis changed its default build environment to Xenial.
    This necessitates some changes to make Travis's testing work.
    
    References:
    * https://blog.travis-ci.com/2019-04-15-xenial-default-build-environment#3-headless-browser-testing
    * https://docs.travis-ci.com/user/gui-and-headless-browsers/#using-xvfb-to-run-tests-that-require-a-gui
    olets committed Jun 25, 2019
    Copy the full SHA
    d4e1d67 View commit details

Commits on Jun 26, 2019

  1. feat(styles): support PostCSS, inc. cssnano + Autoprefixer...

    - Run `yarn add autoprefixer cssnano gulp-postcss'
    - Surface cssnano config option in task-defaults.js
    - Add PostCSS options to task-defaults.js
    - Use PostCSS Autoprefixer and cssnano plugins
    olets committed Jun 26, 2019
    Copy the full SHA
    2859d78 View commit details
  2. feat(styles): support custom settings for Autoprefixer + cssnano

    task-config settings for Autoprefixer and/or cssnano are respected.
    If no user settings are provided, defaults are used.
    olets committed Jun 26, 2019
    Copy the full SHA
    0f0401f View commit details
  3. Copy the full SHA
    cfcd386 View commit details
  4. Copy the full SHA
    189fa88 View commit details

Commits on Jun 28, 2019

  1. Copy the full SHA
    66b9758 View commit details
  2. Merge branch 'postcss' (PR #582)

    olets committed Jun 28, 2019
    Copy the full SHA
    73158fe View commit details

Commits on Oct 29, 2019

  1. chore(bump): v4.5.1

    olets committed Oct 29, 2019
    Copy the full SHA
    ebeec7d View commit details

Commits on Nov 20, 2019

  1. feat(data task): support yaml...

    Adds new dependency 'js-yaml':
    
    >>> yarn add js-yaml
    olets committed Nov 20, 2019
    Copy the full SHA
    2d61470 View commit details
  2. Merge pull request #585 from olets/yaml

    support yaml data source in html task
    olets authored Nov 20, 2019
    Copy the full SHA
    7ac50dd View commit details
  3. Copy the full SHA
    e565ec1 View commit details
  4. chore(bump): v4.5.2

    olets committed Nov 20, 2019
    Copy the full SHA
    3da0e6f View commit details
  5. Copy the full SHA
    3a83cdf View commit details

Commits on Dec 16, 2019

  1. Copy the full SHA
    a2864b0 View commit details
  2. Copy the full SHA
    cb270b2 View commit details
  3. feat(html task): do not specify plugin-default nunjucks option...

    gulp-nunjucks-render's envOptions defaults to watch:false
    olets committed Dec 16, 2019
    Copy the full SHA
    36ea182 View commit details
  4. Merge branch 'twig'

    olets committed Dec 16, 2019
    Copy the full SHA
    c5f1ca0 View commit details
  5. chore(bump): v4.5.3

    olets committed Dec 16, 2019
    Copy the full SHA
    42be028 View commit details

Commits on Feb 19, 2020

  1. Copy the full SHA
    ad7ff99 View commit details

Commits on Apr 14, 2020

  1. Merge branch 'sunset'

    olets committed Apr 14, 2020
    Copy the full SHA
    a824ce4 View commit details
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v8.16.2
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node v8.16.2
7 changes: 3 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -4,10 +4,9 @@ node_js:
- "6.11.1"
- "7.2.0"
- "8.0.0"
before_script:
# http://docs.travis-ci.com/user/gui-and-headless-browsers/#Using-xvfb-to-Run-Tests-That-Require-GUI-(e.g.-a-Web-browser)
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
dist: xenial
services:
- xvfb
script:
- yarn run dev:test
- yarn run build
99 changes: 99 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,104 @@
# Changelog

## 4.5.3

Adds Twig support to the HTML task.

Basic use: in `task-config.js`, set `html.templateLanguage` to `twig`.

```javascript
html : {
templateLanguage: 'twig',
},
```

Advanced use: pass [`gulp-twig` options](https://github.com/zimmen/gulp-twig#options) in `task-config.js`'s `html.twig`

```javascript
html: {
templateLanguage: 'twig',
twig: {…},
},
```

## 4.5.2

- Adds YAML support to the HTML task. Just give your YAML `dataFile` the extension `.yaml` or `.yml`.

## 4.5.1

- Adds PostCSS support
- Autoprefixer replaces gulp-autoprefixer
- cssnano replaces gulp-cssnano

Users can configure `plugins` and `options` in `task-config.js`'s `stylesheets.postcss`. See [gulp-postcss](https://github.com/postcss/gulp-postcss) for more info.

Basic usage is unchanged. Source stylesheets will be preprocessed with Sass unless `stylesheets.sass` is `false`. You can still call out Sass explicitly if you like:

```javascript
// in task-config.js
stylesheets: true
```

A `task-config` with custom PostCSS will look like this

```javascript
// task-config.js
// must also add the dependencies (`(npm i|yarn add) some-plugin some-option`)

var somePlugin = require('some-plugin')
var someOption = require('some-option')

var postCssPlugins = [somePlugin()]
var postCssOptions = {someOption}

module.exports = {
// ...
stylesheets: {
// sass: true is implied
postcss: {
plugins: postCssPlugins,
options: postCssOptions
}
}
// ...
}
```

Autoprefixer and cssnano are injected into the PostCSS plugins list, and do not need to be specified. However custom Autoprefixer and/or cssnano configs are respected if provided. That looks like this:

```javascript
// task-config.js
// must also add the autoprefixer dependency (`(npm i|yarn add) autoprefixer`)

var autoprefixer = require('autoprefixer')

var postCssPlugins = [
autoprefixer({
grid: "autoplace"
})
]

module.exports = {
// ...
stylesheets: {
// sass: true is implied
postcss: {
plugins: postCssPlugins
}
}
// ...
}
```



## 4.5.0
Recommended security-focused upgrade:
- Dependency updates to **resolve security warnings** and resolve deprecation warnings.
- Superficial **breaking change**: the `es2015` Babel preset is no longer supported in the `task-config.js` `javascript` task. Replace `es2015` with `env`. (#573 for more information.)
- Documentation updates

## 4.4.2
- relatively references directories and files within init task

11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
# ![Blendid](https://raw.githubusercontent.com/vigetlabs/blendid/master/extras/blendid-logo.png)
# ![Blendid](https://raw.githubusercontent.com/vigetlabs/blendid/master/blendid-logo.png)

[![Build Status](https://travis-ci.org/vigetlabs/blendid.svg?branch=static-server)](https://travis-ci.org/vigetlabs/blendid)
[![Stories in Ready](https://badge.waffle.io/vigetlabs/blendid.png?label=ready&title=Ready)](https://waffle.io/vigetlabs/blendid)

**Blendid** *(formerly known as Gulp Starter)* is a delicious stand-alone blend of tasks and build tools poured into [Gulp](http://gulpjs.com/) to form a full-featured modern asset pipeline. It can be used as-is as a static site builder, or can be configured and integrated into your own development environment and site or app structure.
**Blendid** is a delicious stand-alone blend of tasks and build tools poured together as a full-featured modern asset pipeline. It can be used as-is as a static site builder, or can be configured and integrated into your own development environment and site or app structure.

## Heads up

**The Viget team is no longer actively developing Blendid.** We will continue to maintain it for existing clients, and if you're interesting in becoming a maintainer [get in touch](https://www.viget.com/contact/)!

## Quick start on a fresh project (empty directory)
```bash
yarn init
yarn add blendid
yarn run blendid -- init
yarn run blendid init
yarn run blendid
```

Binary file added blendid-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed extras/blendid-logo.png
Binary file not shown.
10 changes: 5 additions & 5 deletions extras/docker/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Gulp Starter on Docker
# Blendid on Docker

This extra allows you to run gulp-starter in a Docker container. You can use the included development server, or use Docker to manage assets for another server environment, which may or may not also use Docker.
This extra allows you to run Blendid in a Docker container. You can use the included development server, or use Docker to manage assets for another server environment, which may or may not also use Docker.

## Requirements

@@ -10,7 +10,7 @@ Requires [Docker](https://www.docker.com/products/overview), naturally.

### In development
```bash
git clone https://github.com/vigetlabs/gulp-starter.git MyApp
git clone https://github.com/vigetlabs/blendid.git MyApp
cd MyApp
cp ./extras/docker/Dockerfile .
cp ./extras/docker/.dockerignore .
@@ -26,10 +26,10 @@ Browse to [http://localhost:3000](http://localhost:3000).

### As part of an automated build
```bash
docker run --rm myrepo/myimage:mytag npm run gulp production
docker run --rm myrepo/myimage:mytag yarn run blendid build
```

If you want to use this to process front-end assets for a different server environment, you can do that too. In the Browsersync section of [config.json](https://github.com/davidham/gulp-starter/blob/master/gulpfile.js/config.json), set Browsersync to proxy your app server. Here's an example pointing at a Rails app:
If you want to use this to process front-end assets for a different server environment, you can do that too. In the Browsersync section of [config.json](https://github.com/vigetlabs/blendid/blob/master/gulpfile.js/task-config.json), set Browsersync to proxy your app server. Here's an example pointing at a Rails app:

```json
"browserSync": {
18 changes: 9 additions & 9 deletions extras/rails/ASSETS-README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# Gulp Starter on Rails
# Blendid on Rails
```bash
yarn run blendid -- init-rails
yarn run blendid init-rails
```

Using gulp-starter with Rails (instead of the built in asset pipeline) is actually pretty easy. This directory contains the extra pieces that get put in place by the `init-rails` task.
Using Blendid with Rails (instead of the built in asset pipeline) is actually pretty easy. This directory contains the extra pieces that get put in place by the `init-rails` task.

## Overview
Firstly, note that we're going to leave the existing asset pipeline in place. Many gems rely on it (e.g, Active Admin), and it's a good idea to keep it around. That said, it's important to keep it separated. We won't be mixing gulp-generated assets with rails generated ones.
Firstly, note that we're going to leave the existing asset pipeline in place. Many gems rely on it (e.g, Active Admin), and it's a good idea to keep it around. That said, it's important to keep it separated. We won't be mixing Blendid-generated assets with Rb-generated ones.

Source files should be in a `src` directory in the root of the project, **not** in `app/assets`. You'll also no longer be using the built in Rails asset helpers like `javascript_include_tag` and the like. Instead, you'll use a set of **blendid_asset_helpers** with regular markup.

#### app/helpers/blendid_asset_helper.rb
In production (`yarn run blendid -- build`), filenames get hashed so you can cache them forever. When the file or any of it's referenced assets changes, the hash changes. This works just like the Rails asset pipeline, and we have similar helpers to ensure that the correct filenames are referenced in production:
In production (`yarn run blendid build`), filenames get hashed so you can cache them forever. When the file or any of it's referenced assets changes, the hash changes. This works just like the Rails asset pipeline, and we have similar helpers to ensure that the correct filenames are referenced in production:

```ruby
blendid_asset_path('image/asset.jpg') # -> /image/logo-n39o4orb81.png
@@ -34,7 +34,7 @@ You would do this:
##### Sprite helper
There's also a `<%= icon 'id' %>` helper included for rendering svg icons generated from the `svgSpriteTask` task. Modify as needed.

#### config/initializers/gulp.rb
#### config/initializers/blendid.rb
The asset path helpers check for the existence a rev-manifest.json file, generated by the `build` tasks. It may look something like this:

```json
@@ -54,14 +54,14 @@ For things like Active Admin that rely on the asset pipeline (Sprockets), contin

In some cases, this means you may have two JS files on your page. One containing *only* your gem-installed assets, and one for your bundles compiled with webpack. I try to avoid using gem assets where possible though, and usually just have my webpack bundle on the page.

You may be thinking, "couldn't you still bundle them together, either by including Gulp complied files in the sprockets manifest, or vice versa?" The answer is, yes, technically, but we've been down that road, and it's not a good one to travel. Trust me on this—it's better to keep them separate.
You may be thinking, "couldn't you still bundle them together, either by including Blendid-compiled files in the sprockets manifest, or vice versa?" The answer is, yes, technically, but we've been down that road, and it's not a good one to travel. Trust me on this—it's better to keep them separate.


## Deploying
### Heroku
Heroku makes deploying SUPER easy, but there are a couple of things you'll need to do to get this running.

Since we're using Ruby (to run Rails) AND Node (to compile our assets with Gulp) in our setup, we need both running on our server. Heroku will automatically detect ONE of these at a time based on the presence of a `Gemfile` or `package.json`, but to get both running simultaneously, we need to [specifiy heroku-buildback-multi as your buildpack](https://github.com/ddollar/heroku-buildpack-multi). This enables us to specify multiple custom buildpacks in a `.buildpacks` file.
Since we're using Ruby (to run Rails) AND Node (to compile our assets with Blendid) in our setup, we need both running on our server. Heroku will automatically detect ONE of these at a time based on the presence of a `Gemfile` or `package.json`, but to get both running simultaneously, we need to [specifiy heroku-buildback-multi as your buildpack](https://github.com/ddollar/heroku-buildpack-multi). This enables us to specify multiple custom buildpacks in a `.buildpacks` file.
```
https://github.com/heroku/heroku-buildpack-nodejs.git
https://github.com/orlando/heroku-buildpack-ruby.git
@@ -84,7 +84,7 @@ Take note of the following:
Heroku requires `config.serve_static_files` to be enabled, so be sure to either add `RAILS_SERVE_STATIC_FILES` as a config var in your Heroku settings, or manually set this to true in your `production.rb` file.

#### A note on devDependencies
You'll either need to make sure all dependencies accessed during the production gulp task are included in `dependencies` rather than `devDependencies` or do the following:
You'll either need to make sure all dependencies accessed during the Blendid build task are included in `dependencies` rather than `devDependencies` or do the following:

> Npm reads configuration from any environment variables beginning with NPM_CONFIG. We set production=true by default to install dependencies only. If you would like to install additional devDependencies, you can disable this behavior:
```
2 changes: 1 addition & 1 deletion extras/rails/app/helpers/blendid_asset_helper.rb
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ def blendid_asset_path(path, type = nil)
root = ASSET_PATH_CONFIG['dest'].gsub(/(.*)public\//, '/')
asset_path = type ? File.join(ASSET_PATH_CONFIG[type]['dest'], path) : path
if rev_manifest
raise "#{asset_path} not found in rev_manifest.json. Fix path or try rebuilding with `yarn run blendid -- build` from `/client_side`." if rev_manifest[asset_path].nil?
raise "#{asset_path} not found in rev_manifest.json. Fix path or try rebuilding with `yarn run blendid build` from `/client_side`." if rev_manifest[asset_path].nil?
asset_path = rev_manifest[asset_path]
end
File.absolute_path(File.join(root, asset_path), '/')
2 changes: 1 addition & 1 deletion extras/rails/config/deploy.rb.example
Original file line number Diff line number Diff line change
@@ -4,6 +4,6 @@ before "deploy:assets:precompile", "deploy:blendid_build"
namespace :deploy do
desc "Install front end dependencies and compile for production with Blendid"
task :blendid_build do
invoke_command "bash -c '. /home/deploy/.nvm/nvm.sh && cd #{release_path} && yarn install && yarn run blendid -- build'"
invoke_command "bash -c '. /home/deploy/.nvm/nvm.sh && cd #{release_path} && yarn install && yarn run blendid build'"
end
end
12 changes: 6 additions & 6 deletions extras/shopify/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Gulp Shopify Upload Task
# Blendid Shopify Upload Task

Using gulp-starter with Shopify creates a simple workflow that makes iteration loops fairly tight. This directory contains the extra pieces you'll need to get going.
Using Blendid with Shopify creates a simple workflow that makes iteration loops fairly tight. This directory contains the extra pieces you'll need to get going.

## Overview

@@ -22,17 +22,17 @@ myproject

npm install gulp-shopify-upload --save-dev

#### Gulp Tasks
#### Tasks

This example contains two gulp tasks: `shopifywatch` and `shopifydeploy` defined in `gulpfile.js/tasks/shopify.js`. The watch task starts a watching process that monitors at all Shopify directories and uploads saved files (whether they have changed or not). The deploy task simply deploys all files at once.
This example contains two tasks: `shopifywatch` and `shopifydeploy` defined in `gulpfile.js/tasks/shopify.js`. The watch task starts a watching process that monitors at all Shopify directories and uploads saved files (whether they have changed or not). The deploy task simply deploys all files at once.

Not depicted in this example is the integration of these gulp tasks with your configured task pipelines. It is up to you to add `shopifywatch` to a list of tasks executed during development, and `shopifydeploy` to a deploy task.
Not depicted in this example is the integration of these tasks with your configured task pipelines. It is up to you to add `shopifywatch` to a list of tasks executed during development, and `shopifydeploy` to a deploy task.

**One Caveat**: It is true that, during development, you will actually be deploying (uploading) files to the Shopify server that holds your theme files, overwriting what's there. Keep this in mind! Always develop against a test theme on a dev Shopify project and if you're working with a team, take care not to overwrite eachother's work.

#### API Credentials

In order to upload files, the gulp plugin requires your store's API key and API password, along with the store URL. As you can see in `.gitignore`, it is recommended that you ignore the file with the credentials filled in, and only store the example file in source control. Here's the procedure for setting this up (you probably want to include these instructions in _your_ project's README).
Uploading files requires your store's API key and API password, along with the store URL. As you can see in `.gitignore`, it is recommended that you ignore the file with the credentials filled in, and only store the example file in source control. Here's the procedure for setting this up (you probably want to include these instructions in _your_ project's README).

1. Copy `shopify_api.json.example` and rename it to `shopify_api.json` in the root directory of your project
2. Fill in the fields with your store's information
2 changes: 1 addition & 1 deletion extras/tasks/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Gulp Server Task
## Blendid Server Task
This will start a static server that serves your production files to `http://localhost:5000`. This is primarily meant as a way to preview your production build locally, not necessarily for use as a live production server.

Addtional `devDependencies` needed:
6 changes: 6 additions & 0 deletions gulpfile.js/lib/addPostCssPlugin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = function addPostCssPlugin(name, config) {
let hasPlugin = !!TASK_CONFIG.stylesheets.postcss.plugins.find(p => p.postcssPlugin === name)
if (!hasPlugin) {
TASK_CONFIG.stylesheets.postcss.plugins.push(config)
}
}
26 changes: 17 additions & 9 deletions gulpfile.js/lib/task-defaults.js
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@ module.exports = {
exclude: /node_modules/
},
babel: {
presets: [["es2015", { "modules": false }], 'stage-1']
presets: [["env", { "modules": false }], 'stage-1']
},
development: {},
production: {
@@ -40,21 +40,29 @@ module.exports = {
"./node_modules"
]
},
extensions: ["sass", "scss", "css"]
extensions: ["sass", "scss", "css", "pcss"],
cssnano: {
// deprecated. configure cssnano in stylesheets.postcss.plugins
},
postcss: {
plugins: [
// Autoprefixer and cssnano are added automatically,
// with default settings, if not given custom configuration here
],
options: {}
}
},

html: {
dataFile: "data/global.json",
nunjucksRender: {
envOptions: {
watch: false
}
},
excludeFolders: ["layouts", "shared", "macros", "data"],
extensions: ["html", "njk", "json"],
htmlmin: {
collapseWhitespace: true
},
excludeFolders: ["layouts", "shared", "macros", "data"],
extensions: ["html", "njk", "json"]
nunjucksRender: {},
templateLanguage: 'nunjucks',
twig: {},
},

images: {
31 changes: 25 additions & 6 deletions gulpfile.js/tasks/html.js
Original file line number Diff line number Diff line change
@@ -2,13 +2,15 @@ if(!TASK_CONFIG.html) return

const browserSync = require('browser-sync')
const data = require('gulp-data')
const fs = require('fs')
const gulp = require('gulp')
const gulpif = require('gulp-if')
const handleErrors = require('../lib/handleErrors')
const projectPath = require('../lib/projectPath')
const htmlmin = require('gulp-htmlmin')
const nunjucksRender = require('gulp-nunjucks-render')
const fs = require('fs')
const projectPath = require('../lib/projectPath')
const twig = require('gulp-twig')
const yaml = require('js-yaml')

const htmlTask = function() {

@@ -21,16 +23,33 @@ const htmlTask = function() {

const dataFunction = TASK_CONFIG.html.dataFunction || function(file) {
const dataPath = projectPath(PATH_CONFIG.src, PATH_CONFIG.html.src, TASK_CONFIG.html.dataFile)
return JSON.parse(fs.readFileSync(dataPath, 'utf8'))
const dataExtension = dataPath.split('.').pop()
let data

if (dataExtension === 'yaml' || dataExtension === 'yml') {
data = yaml.safeLoad(fs.readFileSync(dataPath, 'utf8'))
} else {
data = JSON.parse(fs.readFileSync(dataPath, 'utf8'))
}

return data
}

const nunjucksRenderPath = [ projectPath(PATH_CONFIG.src, PATH_CONFIG.html.src) ]
TASK_CONFIG.html.nunjucksRender.path = TASK_CONFIG.html.nunjucksRender.path || nunjucksRenderPath
const templateBasePath = [ projectPath(PATH_CONFIG.src, PATH_CONFIG.html.src) ]
let templateParser

if (TASK_CONFIG.html.templateLanguage === 'twig') {
TASK_CONFIG.html.twig.base = TASK_CONFIG.html.twig.base || templateBasePath
templateParser = twig(TASK_CONFIG.html.twig)
} else {
TASK_CONFIG.html.nunjucksRender.path = TASK_CONFIG.html.nunjucksRender.path || templateBasePath
templateParser = nunjucksRender(TASK_CONFIG.html.nunjucksRender)
}

return gulp.src(paths.src)
.pipe(data(dataFunction))
.on('error', handleErrors)
.pipe(nunjucksRender(TASK_CONFIG.html.nunjucksRender))
.pipe(templateParser)
.on('error', handleErrors)
.pipe(gulpif(global.production, htmlmin(TASK_CONFIG.html.htmlmin)))
.pipe(gulp.dest(paths.dest))
4 changes: 2 additions & 2 deletions gulpfile.js/tasks/rev/rev-assets.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var gulp = require('gulp')
var rev = require('gulp-rev')
var revNapkin = require('gulp-rev-napkin');
var revdel = require('gulp-rev-delete-original')
var projectPath = require('../../lib/projectPath')

// 1) Add md5 hashes to assets referenced by CSS and JS files
@@ -11,7 +11,7 @@ gulp.task('rev-assets', function() {
return gulp.src([projectPath(PATH_CONFIG.dest,'**/*'), ignoreThese])
.pipe(rev())
.pipe(gulp.dest(PATH_CONFIG.dest))
.pipe(revNapkin({ verbose: false, force: true }))
.pipe(revdel())
.pipe(rev.manifest(projectPath(PATH_CONFIG.dest, 'rev-manifest.json'), {merge: true}))
.pipe(gulp.dest(''))
})
4 changes: 2 additions & 2 deletions gulpfile.js/tasks/rev/rev-css.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var gulp = require('gulp')
var rev = require('gulp-rev')
var revNapkin = require('gulp-rev-napkin')
var revdel = require('gulp-rev-delete-original')
var projectPath = require('../../lib/projectPath')

// 3) Rev and compress CSS and JS files (this is done after assets, so that if a
@@ -9,7 +9,7 @@ gulp.task('rev-css', function(){
return gulp.src(projectPath(PATH_CONFIG.dest,'**/*.css'))
.pipe(rev())
.pipe(gulp.dest(PATH_CONFIG.dest))
.pipe(revNapkin({verbose: false, force: true}))
.pipe(revdel())
.pipe(rev.manifest(projectPath(PATH_CONFIG.dest, 'rev-manifest.json'), {merge: true}))
.pipe(gulp.dest(''))
})
4 changes: 2 additions & 2 deletions gulpfile.js/tasks/rev/rev-update-references.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
var gulp = require('gulp')
var revReplace = require('gulp-rev-replace')
var revRewrite = require('gulp-rev-rewrite')
var projectPath = require('../../lib/projectPath')

// 2) Update asset references with reved filenames in compiled css + js
gulp.task('rev-update-references', function(){
var manifest = gulp.src(projectPath(PATH_CONFIG.dest, "rev-manifest.json"))

return gulp.src(projectPath(PATH_CONFIG.dest,'**/**.{css,js}'))
.pipe(revReplace({manifest: manifest}))
.pipe(revRewrite({manifest: manifest}))
.pipe(gulp.dest(PATH_CONFIG.dest))
})
4 changes: 2 additions & 2 deletions gulpfile.js/tasks/rev/update-html.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
if(!TASK_CONFIG.html) return false

var gulp = require('gulp')
var revReplace = require('gulp-rev-replace')
var revRewrite = require('gulp-rev-rewrite')
var projectPath = require('../../lib/projectPath')

// 4) Update asset references in HTML
gulp.task('update-html', function(){
var manifest = gulp.src(projectPath(PATH_CONFIG.dest, "rev-manifest.json"))
return gulp.src(projectPath(PATH_CONFIG.dest, PATH_CONFIG.html.dest, '**/*.html'))
.pipe(revReplace({ manifest: manifest }))
.pipe(revRewrite({ manifest: manifest }))
.pipe(gulp.dest(projectPath(PATH_CONFIG.dest, PATH_CONFIG.html.dest)))
})
52 changes: 37 additions & 15 deletions gulpfile.js/tasks/stylesheets.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
if(!TASK_CONFIG.stylesheets) return

var gulp = require('gulp')
var gulpif = require('gulp-if')
var browserSync = require('browser-sync')
var sass = require('gulp-sass')
var sourcemaps = require('gulp-sourcemaps')
var handleErrors = require('../lib/handleErrors')
var autoprefixer = require('gulp-autoprefixer')
var projectPath = require('../lib/projectPath')
var cssnano = require('gulp-cssnano')
var gulp = require('gulp')
var addPostCssPlugin = require('../lib/addPostCssPlugin')
var autoprefixer = require('autoprefixer')
var browserSync = require('browser-sync')
var cssnano = require('cssnano')
var gulpif = require('gulp-if')
var handleErrors = require('../lib/handleErrors')
var postcss = require('gulp-postcss')
var projectPath = require('../lib/projectPath')
var sass = require('gulp-sass')
var sourcemaps = require('gulp-sourcemaps')

var sassTask = function () {

@@ -17,21 +19,41 @@ var sassTask = function () {
dest: projectPath(PATH_CONFIG.dest, PATH_CONFIG.stylesheets.dest)
}

if(TASK_CONFIG.stylesheets.sass && TASK_CONFIG.stylesheets.sass.includePaths) {
if (TASK_CONFIG.stylesheets.sass && TASK_CONFIG.stylesheets.sass.includePaths) {
TASK_CONFIG.stylesheets.sass.includePaths = TASK_CONFIG.stylesheets.sass.includePaths.map(function(includePath) {
return projectPath(includePath)
})
}

var cssnanoConfig = TASK_CONFIG.stylesheets.cssnano || {}
cssnanoConfig.autoprefixer = false // this should always be false, since we're autoprefixing separately
TASK_CONFIG.stylesheets.autoprefixer = TASK_CONFIG.stylesheets.autoprefixer || {}

TASK_CONFIG.stylesheets.cssnano = TASK_CONFIG.stylesheets.cssnano || {}
TASK_CONFIG.stylesheets.cssnano.autoprefixer = false // this should always be false, since we're autoprefixing separately

TASK_CONFIG.stylesheets.postcss.options = TASK_CONFIG.stylesheets.postcss.options || {}
TASK_CONFIG.stylesheets.postcss.plugins = TASK_CONFIG.stylesheets.postcss.plugins || []

var preprocess = !!TASK_CONFIG.stylesheets.sass

// when watching files, only run once
if (!TASK_CONFIG.stylesheets.configured) {
// ensure Autoprefixer is in the PostCSS config
addPostCssPlugin('autoprefixer', autoprefixer(TASK_CONFIG.stylesheets.autoprefixer))

if (global.production) {
// ensure cssnano is in the PostCSS config
addPostCssPlugin('cssnano', cssnano(TASK_CONFIG.stylesheets.cssnano))
}
}

TASK_CONFIG.stylesheets.configured = true

return gulp.src(paths.src)
.pipe(gulpif(!global.production, sourcemaps.init()))
.pipe(sass(TASK_CONFIG.stylesheets.sass))
.pipe(gulpif(preprocess, sass(TASK_CONFIG.stylesheets.sass)))
.on('error', handleErrors)
.pipe(postcss(TASK_CONFIG.stylesheets.postcss.plugins, TASK_CONFIG.stylesheets.postcss.options))
.on('error', handleErrors)
.pipe(autoprefixer(TASK_CONFIG.stylesheets.autoprefixer))
.pipe(gulpif(global.production, cssnano(cssnanoConfig)))
.pipe(gulpif(!global.production, sourcemaps.write()))
.pipe(gulp.dest(paths.dest))
.pipe(browserSync.stream())
3 changes: 1 addition & 2 deletions gulpfile.js/tasks/watch.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
var gulp = require('gulp')
var watch = require('gulp-watch')
var path = require('path')
var projectPath = require('../lib/projectPath')

@@ -32,7 +31,7 @@ var watchTask = function() {
if(taskConfig) {
var srcPath = projectPath(PATH_CONFIG.src, taskPath.src)
var globPattern = '**/*' + (taskConfig.extensions ? '.{' + taskConfig.extensions.join(',') + '}' : '')
watch(path.join(srcPath, globPattern), watchConfig, function() {
gulp.watch(path.join(srcPath, globPattern), watchConfig, function() {
require('./' + taskName)()
})
}
68 changes: 35 additions & 33 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "blendid",
"version": "4.4.2",
"description": "(formerly gulp-starter) A full featured configurable gulp asset pipeline and static site builder",
"version": "4.5.3",
"description": "A full featured configurable asset pipeline and static site builder",
"license": "MIT",
"engines": {
"node": ">=6.11.1",
"node": ">=6.11.1 <10",
"npm": ">=3.10.3"
},
"main": "gulpfile.js/index.js",
@@ -24,51 +24,53 @@
"dev:test": "mocha ./gulpfile.js/**/*.test.js"
},
"dependencies": {
"ansi-colors": "^1.0.1",
"babel-core": "^6.25.0",
"ansi-colors": "^3.2.4",
"autoprefixer": "^9.6.0",
"babel-core": "^6.26.3",
"babel-loader": "^7.1.1",
"babel-preset-es2015": "^6.24.1",
"babel-preset-env": "^1.7.0",
"babel-preset-stage-1": "^6.24.1",
"browser-sync": "^2.18.8",
"del": "2.2.2",
"es6-promise": "^4.1.1",
"fancy-log": "^1.3.2",
"browser-sync": "^2.26.3",
"cssnano": "^4.1.10",
"del": "4.0.0",
"es6-promise": "^4.2.6",
"fancy-log": "^1.3.3",
"gulp": "3.9.1",
"gulp-autoprefixer": "3.1.1",
"gulp-changed": "^2.0.0",
"gulp-cssnano": "2.1.2",
"gulp-data": "1.2.1",
"gulp-changed": "^3.2.0",
"gulp-data": "1.3.1",
"gulp-gh-pages": "0.5.4",
"gulp-htmlmin": "3.0.0",
"gulp-htmlmin": "5.0.1",
"gulp-if": "2.0.2",
"gulp-notify": "^3.0.0",
"gulp-nunjucks-render": "^2.2.1",
"gulp-rename": "1.2.2",
"gulp-replace": "^0.5.4",
"gulp-rev": "7.1.2",
"gulp-rev-napkin": "0.1.0",
"gulp-rev-replace": "0.4.3",
"gulp-sass": "^3.1.0",
"gulp-sequence": "0.4.6",
"gulp-sizereport": "1.2.0",
"gulp-sourcemaps": "^2.6.0",
"gulp-svgstore": "6.1.0",
"gulp-watch": "4.3.11",
"lodash": "^4.17.4",
"gulp-notify": "^3.2.0",
"gulp-nunjucks-render": "^2.2.2",
"gulp-postcss": "^8.0.0",
"gulp-rename": "^1.4.0",
"gulp-replace": "^1.0.0",
"gulp-rev": "9.0.0",
"gulp-rev-delete-original": "^0.2.3",
"gulp-rev-rewrite": "^1.1.4",
"gulp-sass": "^4.0.2",
"gulp-sequence": "1.0.0",
"gulp-sizereport": "1.2.1",
"gulp-sourcemaps": "^2.6.5",
"gulp-svgstore": "7.0.1",
"gulp-twig": "^1.2.0",
"js-yaml": "^3.13.1",
"lodash": "^4.17.11",
"merge-stream": "^1.0.1",
"minimist": "^1.2.0",
"node-fs-extra": "^0.8.2",
"node-sass-glob-importer": "^5.0.0-alpha.5",
"node-sass-glob-importer": "^5.3.0",
"open": "0.0.5",
"plugin-error": "^0.1.2",
"plugin-error": "^1.0.1",
"pretty-hrtime": "1.0.3",
"require-dir": "0.3.2",
"require-dir": "1.2.0",
"webpack": "^3.4.1",
"webpack-dev-middleware": "^1.12.0",
"webpack-hot-middleware": "^2.18.2"
},
"devDependencies": {
"chai": "^3.5.0",
"mocha": "3.2.0"
"mocha": "^6.0.2"
}
}
7,676 changes: 4,881 additions & 2,795 deletions yarn.lock

Large diffs are not rendered by default.