webpack-auto-inject-version/README.md

105 lines
2.2 KiB
Markdown
Raw Normal View History

2016-10-20 17:58:19 +11:00
# In development
2016-10-20 19:32:26 +11:00
## What
2016-10-21 18:32:35 +11:00
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 <{version}>
- inject version from package.json into any place in CSS/JS file by special tag <{version}>
- auto increase version by --major, --minor, --patch and then inject as chosen
## Desc
2016-10-20 19:32:26 +11:00
AIV can inject version number for all your bundle files (css,js,html).<br><br>
Example js:
```js
// [AIV] Build version: 1.0.10
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
```
<br><br>
Example html:
```html
<!-- [AIV] Build version: 1.0.10 -->
<!DOCTYPE html>
<html lang="en">
```
2016-10-20 17:58:19 +11:00
2016-10-20 19:32:26 +11:00
AIV can also auto inject your version number into html by using special code ( <{version}> ).<br><br>
Example:
```html
<span>My awesome project | <{version}></span>
```
2016-10-20 17:58:19 +11:00
2016-10-20 19:32:26 +11:00
<br>
## Install
```console
$ npm install webpack-auto-inject-version --save-dev
```
<br>
## Usage
```js
var WebpackAutoInject = require('webpack-auto-inject-version');
module.exports = {
2016-10-20 17:58:19 +11:00
plugins: [
2016-10-21 18:32:35 +11:00
new WebpackAutoInject(options)
2016-10-20 17:58:19 +11:00
]
2016-10-20 19:32:26 +11:00
}
```
<br>
## Options
### autoIncrease
Auto increase package.json number. <br>
This option requires extra argument to be sent to webpack build. <br>
2016-10-21 18:32:35 +11:00
It happens before anything else to make sure that your new version is injected into your files.<br>
2016-10-20 19:32:26 +11:00
Arguments: --major --minor --patch<br><br>
<br>
Example for package.json run type, npm run start => ( 1.2.10 to 2.0.0 )
```json
"version" : "1.2.10",
"scripts": {
"start": "webpack --major"
}
```
Default: true
<br>
2016-10-21 18:32:35 +11:00
### injectByTag
Inject version number into your file<br>
Version will replace the <{version}> tag.<br>
2016-10-20 19:32:26 +11:00
```html
<span>My awesome project | <{version}></span>
```
2016-10-21 18:32:35 +11:00
```js
var version = '<{version}>';
```
2016-10-20 19:32:26 +11:00
Default: true
<br>
2016-10-21 18:32:35 +11:00
### injectByTagFileRegex
Regex against file name. If match, injectByTag will try to find version tag and replace it.
Only html files: /^(.){1,}\.html$/ <br>
Only js files: ^(.){1,}\.js$ <br>
Any file: (.){1,} <br>
2016-10-20 19:32:26 +11:00
Default: /^index\.html$/
<br>
2016-10-20 17:58:19 +11:00
2016-10-21 18:32:35 +11:00
### injectAsComment
This will inject your version as a comment into any css,js,html file.<br>
2016-10-20 19:32:26 +11:00
Default: true