webpack-auto-inject-version/README.md
2016-10-21 08:32:35 +01:00

2.2 KiB

In development

What

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

AIV can inject version number for all your bundle files (css,js,html).

Example js:

// [AIV] Build version: 1.0.10
/******/ (function(modules) { // webpackBootstrap
/******/ 	// The module cache
/******/ 	var installedModules = {};



Example html:

<!-- [AIV] Build version: 1.0.10 -->
<!DOCTYPE html>
<html lang="en">

AIV can also auto inject your version number into html by using special code ( <{version}> ).

Example:

<span>My awesome project | <{version}></span>

Install

$ npm install webpack-auto-inject-version --save-dev

Usage

var WebpackAutoInject = require('webpack-auto-inject-version');

module.exports = {
    plugins: [
        new WebpackAutoInject(options)
    ]
}

Options

autoIncrease

Auto increase package.json number.
This option requires extra argument to be sent to webpack build.
It happens before anything else to make sure that your new version is injected into your files.
Arguments: --major --minor --patch


Example for package.json run type, npm run start => ( 1.2.10 to 2.0.0 )

 "version" : "1.2.10",
 "scripts": {
    "start": "webpack --major"
 }

Default: true


injectByTag

Inject version number into your file
Version will replace the <{version}> tag.

<span>My awesome project | <{version}></span>
var version = '<{version}>';

Default: true


injectByTagFileRegex

Regex against file name. If match, injectByTag will try to find version tag and replace it. Only html files: /^(.){1,}.html$/
Only js files: ^(.){1,}.js$
Any file: (.){1,}
Default: /^index.html$/


injectAsComment

This will inject your version as a comment into any css,js,html file.
Default: true