Skip to content

v4.1.0

Compare
Choose a tag to compare
@cossssmin cossssmin released this 19 Sep 17:46
· 601 commits to master since this release

New features

CSS selectors urlParameters tags

As requested in #749, you may now use CSS selectors to select only certain tags or attributes to apply URL parameters to:

module.exports = {
  urlParameters: {
    _options: {
      tags: ['a.button', 'a[href*="example.com"]', 'link'],
    },
    utm_source: 'maizzle',
  }
}

This way you can apply parameters only to specific URLs, or only to URLs on certain <a> tags, for example.

Simplified baseURL tags list

It's now easier to apply a baseURL to just a few tags, by simply passing in the tags list in array format:

module.exports = {
  baseURL: {
    url: 'https://cdn.example.com/',
    tags: ['img'],
  },
}

That will apply the url to all known source attributes on all <img> elements in your HTML, like src="" or srcset=".

Support for @font-face in baseURL

The baseURL transformer now prepends URLs to url() sources in @font-face declarations.

build.current.path

The config now contains build.current.path, an object containing a parsed path of the currently being processed template file:

module.exports = {
  build: {
    current: {
      path: {
        root: '',
        dir: 'build_production',
        base: 'transactional.html',
        ext: '.html',
        name: 'transactional'
      }
    }
  }
}

strict option for urlParameters

By default, the urlParameters transformer will append query parameters only to valid URLs.

You may disable strict mode to append parameters to any string:

module.exports = {
  urlParameters: {
    _options: {
      strict: false,
    },
    foo: 'bar'
  }
}

Input:

<a href="example.com">test</a>

Result:

<a href="example.com?foo=bar">test</a>

v4.0.3...v4.1.0