Skip to content

Instantly share code, notes, and snippets.

@tdhsmith
Last active November 16, 2015 20:23
Show Gist options
  • Save tdhsmith/65ee268a2a457b025aa2 to your computer and use it in GitHub Desktop.
Save tdhsmith/65ee268a2a457b025aa2 to your computer and use it in GitHub Desktop.
Usemin Generic Steps

Usemin-Generic-Steps

The purpose of this mini-package is to provide a set of generic createConfig templates that can be used to quickly create new grunt-usemin flow steps.

Minimal example usage:

var customStepJS = {
  'name': 'GRUNT-TASK-NAME',
  'createConfig': require('usemin-generic-steps').independentFlow
};

grunt.initConfig({
  useminPrepare: {
    options: {
      flow: {
        html: {
          steps: {
            js: [customStepJS, 'uglifyjs']
}}}}}});
'use strict';
var path = require('path');
// a generic flow step where each file is processed independently
// from the inDir to the outDir (this doesn't have a 'last case')
// (borrowed from the default uglify task)
exports.independentFlow = function (context, block) {
var config = {files: []};
context.inFiles.forEach(function (filename) {
var infile = path.join(context.inDir, filename);
var outfile = path.join(context.outDir, filename);
config.files.push({
src: [infile],
dest: outfile
});
context.outFiles.push(filename);
});
return config;
};
{
"name": "usemin-generic-steps",
"version": "0.0.2",
"main": "index.js"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment