Go to file
radswiat 05e79420c4 Long awaited improvements, in progress 2017-04-10 21:33:32 +01:00
demo Long awaited improvements, in progress 2017-04-10 21:33:32 +01:00
dist Long awaited improvements, in progress 2017-04-10 21:33:32 +01:00
src Long awaited improvements, in progress 2017-04-10 21:33:32 +01:00
tools Long awaited improvements, in progress 2017-04-10 21:33:32 +01:00
.babelrc Long awaited improvements, in progress 2017-04-10 21:33:32 +01:00
.gitignore first commit 2016-10-20 07:58:19 +01:00
.npmignore first commit 2016-10-20 07:58:19 +01:00
README.md Readme desc change 2016-10-21 09:04:52 +01:00
package.json Long awaited improvements, in progress 2017-04-10 21:33:32 +01:00

README.md

Auto inject version - Webpack plugin

Add version to bundle automatically

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