npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

grunt-azure-blob

v0.0.2

Published

Grunt task to copy html assets to azure blob/cdn storage

Downloads

509

Readme

grunt-azure-blob

A Grunt task for copying html assets to azure blob/cdn storage.

Installation

Install npm package next to your projects gruntfile.js file

    npm install grunt-azure-blob

Add this line to your projects Gruntfile.js

    grunt.loadNpmTasks('grunt-azure-blob');

Environment Requirment

  • The Azure SDK provides a Node.js package for access to the Azure Table Storage. By default, this library uses the following environment variables for authentication (set as required as global, user, or with a task). I've had great success with grunt-env to manage the these settings as a task (sample usage shown below). These environment variables must be set to your appropriate values!
    • AZURE_STORAGE_ACCOUNT
    • AZURE_STORAGE_ACCESS_KEY

AzureBlob Options and default values

grunt-azureblob is a multi task that implicity iterates over all of the named sub-properties (targets). In addition to the default properties , task specific properties are also available inside each task function. Options are essentially globally available (across tasks), but can be overridden / set at each task level as needed.

    {
      serviceOptions: [], // custom arguments to azure.createBlobService
      containerName: null, // container name, required
      containerDelete: false, // deletes container if it exists
      containerOptions: {publicAccessLevel: "blob", timeoutIntervalInMs: 10000}, // container
      copySimulation: false, // do everything but physically touch storage blob when true
      metadata: {cacheControl: 'public, max-age=31556926'}, // file metadata properties
      gzip: false, // gzip files
      maxNumberOfConcurrentUploads: 10 // Maximum number of concurrent uploads
    };

Example Gruntfile.js

'use strict';

module.exports = function(grunt) {
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    env : {
      options : {
        //Shared Options Hash
      },
      configCDN : {
        AZURE_STORAGE_ACCOUNT : process.env.AZURE_STORAGE_ACCOUNT,
        AZURE_STORAGE_ACCESS_KEY : process.env.AZURE_STORAGE_ACCESS_KEY
      }
    },
    'azure-blob': {
      options: { // global options applied to each task
        containerName: 'grunt-azure-blob',
        containerDelete: false, //do not apply true here, container would be deleted at each task
        metadata: {cacheControl: 'public, max-age=31556926'}, // max-age 1 year for all entries
        gzip: true,
        copySimulation: false  // set true: only dry-run what copy would look like
      },
      css: {
        files: [{
          expand: true,
          cwd: 'example/css/',
          dest: '<%= pkg.version %>/css/',
          src: ['*.css']
        }]
      },
      js: {
        files: [{
          expand: true,
          cwd: 'example/js/',
          dest: '<%= pkg.version %>/js/',
          src: ['*.js']
        }]
      }
    }
  });

// Load the plugin that provides all the pirate magic grunt.loadTasks('tasks');

// Default task(s). grunt.registerTask('default', ['azure-blob']); };

Sample console run (from Gruntfile.js)

Running "azure-blob:css" (azure-blob) task
skiping delete of container[grunt-azure-blob]...OK
azure-blob:css - Create blob container [grunt-azure-blob] ....OK
Copy example.css => grunt-azure-blob/0.0.1/css/example.css - text/css OK
blobStorage copy completed (1) files...OK

Running "azure-blob:js" (azure-blob) task
skiping delete of container[grunt-azure-blob]...OK
azure-blob:js - Create blob container [grunt-azure-blob] ....OK
Copy example.js => grunt-azure-blob/0.0.1/js/example.js - application/javascript OK
blobStorage copy completed (1) files...OK

Original source

https://github.com/jstott/grunt-azureblob