Skip to content

Webpack plugin to copy version number from package.json to manifest.json or any other json files with version property

License

Notifications You must be signed in to change notification settings

mazillka/webpack-copy-version-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

webpack-copy-version-plugin

A simple Webpack plugin to copy the version number from package.json to manifest.json or any other JSON file with a version property.

Installation

npm install --save-dev webpack-copy-version-plugin

Usage

Add the plugin to your webpack.config.js:

const CopyVersionPlugin = require("webpack-copy-version-plugin");

module.exports = {
  // ...other webpack config...
  plugins: [
    new CopyVersionPlugin({
      from: "package.json",   // optional, defaults to "package.json"
      to: "manifest.json"     // optional, defaults to "manifest.json"
    })
  ]
};

Options

  • from: string
    Path or filename to read the version from. Defaults to "package.json".

  • to: string
    Path or filename to write the version to. Defaults to "manifest.json".

How it works

During the Webpack build, this plugin reads the version property from the from file and writes it to the version property in the to file, preserving other properties.

Example

If your package.json contains:

{
  "name": "my-app",
  "version": "1.2.3"
}

And your manifest.json contains:

{
  "name": "My App",
  "version": "0.0.0"
}

After running Webpack, manifest.json will be updated to:

{
  "name": "My App",
  "version": "1.2.3"
}

About

Webpack plugin to copy version number from package.json to manifest.json or any other json files with version property

Resources

License

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •