A simple Webpack plugin to copy the version number from package.json to manifest.json or any other JSON file with a version property.
npm install --save-dev webpack-copy-version-pluginAdd 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"
})
]
};-
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".
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.
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"
}