From 381f03eb97885a02da9f26b5c0bbf7d62e7864a5 Mon Sep 17 00:00:00 2001 From: Niklas Date: Sat, 25 Apr 2020 22:35:27 +0200 Subject: [PATCH] set current version in manifest --- .eslintrc.json | 5 ++++- src/manifest.json | 2 +- webpack.config.js | 22 ++++++++++++++++++---- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index d112697..aaa6011 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -18,5 +18,8 @@ "ecmaFeatures": { "jsx": true } - } + }, + "globals": { + "VERSION": true + } } diff --git a/src/manifest.json b/src/manifest.json index de63979..599efdc 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 2, "name": "Startpage", - "version": "0.2.0", + "version": "$VERSION", "description": "Startpage", "developer": { "name": "Djeeberjr" diff --git a/webpack.config.js b/webpack.config.js index aeb2aeb..210184d 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -4,10 +4,18 @@ const HtmlWebpackPlugin = require("html-webpack-plugin"); const MiniCssExtractPlugin = require("mini-css-extract-plugin"); const CopyWebpackPlugin = require('copy-webpack-plugin'); +const Webpack = require("webpack"); + const path = require("path"); const DEVELOPMENT = process.env.NODE_ENV === "development"; +const version = require('child_process') + .execSync("git describe --abbrev=0") + .toString() + .replace("v", "") + .trim(); + module.exports = { context: path.join(__dirname, "src"), resolve: { @@ -64,10 +72,16 @@ module.exports = { }), new MiniCssExtractPlugin(), new CopyWebpackPlugin([ - { - from : "manifest.json", - to: ".." + { + from: "manifest.json", + to: "..", + transform(content) { + return content.toString().replace("$VERSION", version); + } } - ]) + ]), + new Webpack.DefinePlugin({ + VERSION: JSON.stringify(version), + }) ] };