Gulp plugin for managing version of assets, easy to build new version to commit and deploy.
- Generate new file for js,css etc. based on md5 of file contents
- Create new version only for changed assets
- Auto replace versioned assets in template files, like php, python Django, Expressjs ejs and etc.
1. File structure
Files under js_build and css_build are generated by compass uglify
Links in templates：
__placeholder__ is a placeholder when it has not been versioned yet
2. Configs in gulpfile.js：
3. Run gulp task
gulp assetsVersionReplace in your terminal.
Your get these result:
- Files named with generated version
- Links in templates have been replaced with generated version
The changes of template contain version string, commit directly if you are deployoing a static site.
In some case templates are created by other gulp task before replacing version string.
versionsAmount: 0 option is introduced for this reason.
See following example, the templates in the dist folder are always have
__placeholder__ as they are copied from dev folder each time run gulp task. Setting
versionsAmount: 0 will make version replacing works in this case.
A gulp4 example of using this plugin is here: gulp-workflow
npm install gulp-assets-version-replace --save-dev
In your gulpfile.js place this line:
var assetsVersionReplace = ;
A json file called
gulp-assets-version-replace-version.json will be created beside your gulpfile.js to store versions.
Form asset link as following in your template:
__placeholder__ is a placeholder for replacing with generated versions at first time
Gulp Plugin Options
How many versions to keep in your local json file. Set
0 to disable local save.
List of templates which contain assets links of
tsFiles . Support whatever extension like php, python Django, Express and etc. Make sure give templates paths relative to gulpfile.js.
- 2015-12-19 v2.1.0 More stable now
- 2015-12-16 v2.0.0 More standard for gulp pipe
- 2015-12-15 v1.0.0