Socket
Book a DemoInstallSign in
Socket

cdnify-grunt

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cdnify-grunt

Converts local URLs to CDN ones.

0.0.2
latest
Source
npmnpm
Version published
Weekly downloads
4
100%
Maintainers
1
Weekly downloads
 
Created
Source

grunt-cdnify Build Status Dependency Status

Grunt plugin for rewriting static resource URLs found in your HTML and CSS.

What it does

The task looks through your specified files for URLs to rewrite, in the following places:

  • <img src="____">
  • <script src="____"></script>
  • <link rel="stylesheet" href="____">
  • background-image: url(____); in your CSS (including inside <style> tags in your HTML)

See options below for how it modifies them.

Options

You should set either base or rewriter (not both).

base

For the most common use case, just set a base string for your URLs – eg, '//cdn.example.com/'. The cdnify task will automatically search for all local URLs in your files, and prefix them with this string. (It will automatically avoid double-slashes.)

Example:

cdnify: {
  someTarget: {
    options: {
      base: '//cdn.example.com/stuff/'
    },
    files: [{
      expand: true,
      cwd: 'app',
      src: '**/*.{css,html}',
      dest: 'dist'
    }]
  }
}

rewriter

For more control, you can specify a custom rewriter function instead. In this case, the task will search for all URLs (not just local ones) and run your function on each one. Your function should return the new value.

Example:

cdnify: {
  someTarget: {
    options: {
      rewriter: function (url) {
        if (url.indexOf('data:') === 0)
          return url; // leave data URIs untouched
        else
          return url + '?12345'; // add query string to all other URLs
      }
    },
    files: [{
      expand: true,
      cwd: 'app',
      src: '**/*.{css,html}',
      dest: 'dist'
    }]
  }
}

Keywords

gruntplugin

FAQs

Package last updated on 29 Jul 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.