# Auto inject version - Webpack plugin
Adds version from package.json into every single file as top comment block.
# Install
```console
$ npm install webpack-auto-inject-version --save-dev
```
# Table of Contents
[What it does](#user-content-what-it-does)
[How to use](#user-content-how-to-use)
[Available options](#user-content-available-options)
[Output examples](#user-content-output-examples)
[Change log](#user-content-change-log)
# What it does
Auto Inject Version (AIV) can:
- inject version from package.json into every bundle file as a comment ( at the top )
- inject version from package.json into any place in your HTML by special tag `[AIV]{version}[/AIV]`
- inject version from package.json into any place in CSS/JS file by special tag `[AIV]{version}[/AIV]`
- auto increase package.json version by --env.major, --env.minor, --env.patch passed into webpack
# How to use
It's easy to set it up, all you need is:
* use WebpackAutoInject in webpack plugins
* pass config as a parameter, or leave it blank as all options are "on" by default.
### More info
* Date format masks [dateFormat](https://github.com/felixge/node-dateformat#mask-options)
+ Version management [semver](https://github.com/npm/node-semver)
### Simple config example ( in webpack.conf.js )
```js
var WebpackAutoInject = require('webpack-auto-inject-version');
...
module.exports = {
...
plugins: [
new WebpackAutoInject({
// options
// example:
components: {
AutoIncreaseVersion: false
}
})
]
}
```
### Full config example ( in webpack.conf.js )
```
module.exports = {
...
plugins: [
new WebpackAutoInject({
NAME: 'AIV custom name',
SHORT: 'CUSTOM',
SILENT: false,
PACKAGE_JSON_PATH: './package.json',
components: {
AutoIncreaseVersion: true,
InjectAsComment: true,
InjectByTag: true
},
componentsOptions: {
AutoIncreaseVersion: {
runInWatchMode: false // it will increase version with every single build!
},
InjectAsComment: {
tag: 'Version: {version} - {date}',
dateFormat: 'h:MM:ss TT'
},
InjectByTag: {
fileRegex: /\.+/,
dateFormat: 'h:MM:ss TT'
}
},
LOGS_TEXT: {
AIS_START: 'DEMO AIV started'
}
})
]
}
```
### Inject by tag example
```