Version static assets.
Version static assets
This plugin requires Grunt
If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
npm install grunt-static-versioning --save-dev
NOTE: This plugin requires some extra work on your end. It will create the versioned assets and a config file (PHP and JSON at the moment with more to come), but you will need to write an adapter to use that file. There will be examples in this repo under the
Specify the location of the outputted files. This is generally the root folder of the web project, e.g. the public directory. This path is excluded from the final file output.
Specify which files the task will copy over to the destination directory. Can be:
Specify the type of config file to generate. This will generate an
assets.config.[ EXTENSION ] file which can be used to insert the proper files in the source. The config file will only contain paths to development or minified files based on the
env option. Can be:
Specify the location where the config file will be generated. If left empty, it will used the
Namespace wrapping the file assets config generated file.
An array of files that will be versioned. They can be manually entered or leveraged from the
cssmin tasks. NOTE: If the files are provided manually, they MUST exist. This task does NOT concat/minify any files, it simply renames and copies existing files to proper destination.
Offers an additional level of organization. The task options'
dest paramater provided access to the web public folder while this option offers the organizational directories. E.g.
This option is used to create structure to the config object the task creates. Can be:
The extension to apply to the files. Files will follow the naming pattern:
The key is used to organize the files in the config file. The same key can be used multiple times to organized multiples files together.
If set to true, the file will bypass versioning and simply append the given extension.
This task is built to leverage other existing tasks. Instead of manually providing the files array, it can be read from the
The above example would output:
public/js/main.[ MD5_HASH ].min.js
public/js/plugin.min.js(no hash because of
public/css/main.[ MD5_HASH ].min.css
"staticAssets":"global": // <--- 'key' option"js":"/js/main.c2e864c8.min.js""/js/plugin.min.js""css":"/css/main.b6f17edb.min.css""all": // <--- 'key' option"js":"/js/all.625a4fd0.min.js""css":
"staticAssets":"global": // <--- 'key' option"js":"/js/file1.js""/js/file2.js""/js/test.js""/js/file3.js""/js/file4.js""css":"/css/main.css""all": // <--- 'key' option"js":"/js/file1.js""/js/file2.js""/js/file3.js""/js/file4.js""css":
Copyright (c) 2013 CanvasPop
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.