Skip to content

Support for multiple patterns with different settings for each #50

@dannyfallon

Description

@dannyfallon

We're currently uploading to S3 via a Grunt plugin. It allows considerable flexibility over the current S3 plugin that I'm interested in seeing if I can get some consensus on. Consider the following example of our setup:

module.exports = function(grunt) {
  return {
    release: {
      files: [
        {
          cwd: 'dist/assets/',
          dest: 'ember/',
          expand: true,
          src: ['*.css'],
          params: {
            ContentType: 'text/css; charset=utf8'
          }
        },
        {
          cwd: 'dist/assets/',
          dest: 'ember/',
          expand: true,
          src: ['*.js'],
          params: {
            ContentType: 'application/javascript; charset=utf8'
          }
        },
        {
          cwd: 'dist/assets/',
          dest: 'ember/',
          expand: true,
          src: ['*.gz'],
        },
        {
          cwd: 'dist/assets/',
          dest: 'ember/assets',
          expand: true,
          src: ['**/*.!(js|css|gz)', '!assetMap.json', '!failed-*.png', "!passed-*.png"]
        }
      ],
      options: {
        access: 'public-read',
        bucket: '...',
        region: '...',
        uploadConcurrency: 16,
        sslEnabled: true
      }
    }
  };
};

Firstly, pattern arrays are supported. This has a few advantages, but what we use it here for is negation. I see from the gzip plugin that support for an ignorePattern option was added, is this how you intend to proceed with other plugins? I see the pattern array with matching left to right as being more powerful and flexible than the current approach, if only because it allows multiple patterns and won't require extra parameters to be passed through promises.

The second thing I see here is that we're able to specify specific content-types and destinations for each pattern group. Is this something you could see a use for?

I've tried to sidestep this problem entirely by hooking a private plugin into the didBuild step, moving the JS/CSS in the <distDir>/assets directory out to the parent directory but alas each Pipeline's returning context is merged with what exists already, meaning you can't delete existing context - in this case I can't delete the <distDir>/assets/*.{js,css} files and later plugins bomb out when they try to access the non-existent files.

I could probably achieve what I desire with a custom upload client but that'd just be private and I'm interested in contributing if there's some agreement, though given the time pressure I'm under I reckon a custom upload client is going to happen anyways 😄

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions