No description
Find a file
2017-04-12 22:47:11 +01:00
demo Add editor config, fix unnecessary .default suffix 2017-04-12 22:11:59 +01:00
dist Fix eslint issues 2017-04-12 22:32:39 +01:00
src Fix eslint issues 2017-04-12 22:32:39 +01:00
tools Fix eslint issues 2017-04-12 22:32:39 +01:00
.babelrc Fix eslint issues 2017-04-12 22:32:39 +01:00
.editorconfig Add editor config, fix unnecessary .default suffix 2017-04-12 22:11:59 +01:00
.eslintrc Fix eslint issues 2017-04-12 22:32:39 +01:00
.gitignore Finilize new version 2017-04-11 00:11:09 +01:00
.npmignore Remove demo/ from npm 2017-04-12 21:54:57 +01:00
package.json Update readme file 2017-04-12 22:47:11 +01:00
README.md Update readme file 2017-04-12 22:47:11 +01:00

Auto inject version - Webpack plugin

Adds version from package.json into every single file as top comment block.

Install

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

Table of Contents

What it does How to use Available options Examples of the plugin outputs

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.

Example ( in webpack.conf.js )

var WebpackAutoInject = require('webpack-auto-inject-version');
...
module.exports = {
    ...
    plugins: [
        new WebpackAutoInject({
            // options
            // example:
            components: {
                AutoIncreaseVersion: false
            }
        })
    ]
}

Available options

components.AutoIncreaseVersion

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: --env.major --env.minor --env.patch

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

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

Default: true

components.InjectByTag

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

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

Default: true

components.InjectAsComment

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

Examples of the plugin outputs

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

// [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">