Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

webpack-auto-inject-version

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

webpack-auto-inject-version

Webpack plugin for auto inject version from package.json

  • 0.5.11
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

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

What it gives you

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

Example

Please take a look into demo/ folder.

Inject example

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

How to configure

In webpack.conf.js ( or any name of webpack conf file )

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

module.exports = {
    plugins: [
        new WebpackAutoInject({
            // options
            // example:
            components: {
                AutoIncreaseVersion: false
            }
        })
    ]
}

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

Development advice

Demo has been created to simplify the testing of the webpack-plugin, if you would like to work on this webpack plugin you should:

  • clone the repo
  • npm install on ./ & ./demo
  • npm start on ./
  • and then you can test your code by demo/ npm start

FAQs

Package last updated on 12 Apr 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc