Skip to content

Commit

Permalink
Merge pull request #111 from Opetushallitus/feature/OPHAKTKEH-366
Browse files Browse the repository at this point in the history
AKT(Frontend): Show git branch and hash in meta tag
  • Loading branch information
p3j4m authored Jun 7, 2022
2 parents 331b9c4 + bf6ce63 commit 46f4f36
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
"eslint-plugin-react": "^7.29.4",
"eslint-plugin-react-hooks": "^4.4.0",
"eslint-webpack-plugin": "^3.1.1",
"git-revision-webpack-plugin": "^5.0.0",
"html-webpack-plugin": "^5.5.0",
"jest": "^27.5.1",
"mini-css-extract-plugin": "^2.6.0",
Expand Down
1 change: 1 addition & 0 deletions frontend/packages/akt/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
name="viewport"
content="width=device-width, initial-scale=1, shrink-to-fit=no"
/>
<meta name="version" content="<%= GIT_INFO %>" />
<!-- TODO: Remove this before going to production -->
<meta name="robots" content="noindex, nofollow" />
<link
Expand Down
17 changes: 13 additions & 4 deletions frontend/packages/akt/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,16 @@ const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyPlugin = require('copy-webpack-plugin');
const CompressionPlugin = require('compression-webpack-plugin');
const { GitRevisionPlugin } = require('git-revision-webpack-plugin');

module.exports = (env) => {
const STATIC_PATH = 'akt/static';
const mode = env.prod ? 'production' : 'development';

const gitRevisionPlugin = new GitRevisionPlugin({
branch: true,
});

return {
mode,
entry: path.join(__dirname, 'src', 'index.tsx'),
Expand All @@ -34,10 +39,6 @@ module.exports = (env) => {
new MiniCssExtractPlugin({
filename: `${STATIC_PATH}/css/[name].css`,
}),
new HtmlWebpackPlugin({
publicPath: env.prod ? '/akt/' : '/',
template: path.join(__dirname, 'public', 'index.html'),
}),
new CopyPlugin({
patterns: [
{
Expand All @@ -46,9 +47,17 @@ module.exports = (env) => {
},
],
}),
gitRevisionPlugin,
new webpack.DefinePlugin({
REACT_ENV_PRODUCTION: JSON.stringify(Boolean(env.prod)),
}),
new HtmlWebpackPlugin({
publicPath: env.prod ? '/akt/' : '/',
template: path.join(__dirname, 'public', 'index.html'),
templateParameters: {
GIT_INFO: `${gitRevisionPlugin.branch()}-${gitRevisionPlugin.commithash()}`,
},
}),
...getESLintPlugin(env),
...getStylelintPlugin(env),
],
Expand Down
10 changes: 10 additions & 0 deletions frontend/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2376,6 +2376,7 @@ __metadata:
eslint-plugin-react-hooks: ^4.4.0
eslint-webpack-plugin: ^3.1.1
finnish-personal-identity-code-validator: ^2.1.0
git-revision-webpack-plugin: ^5.0.0
html-webpack-plugin: ^5.5.0
i18next: ^21.6.16
i18next-browser-languagedetector: ^6.1.4
Expand Down Expand Up @@ -6628,6 +6629,15 @@ __metadata:
languageName: node
linkType: hard

"git-revision-webpack-plugin@npm:^5.0.0":
version: 5.0.0
resolution: "git-revision-webpack-plugin@npm:5.0.0"
peerDependencies:
webpack: ^5.0.0
checksum: be40634cf0a317f02b6231e77a7f97f5ae85855f87d88ee821500e8ad33a25168b96d47f1be8f2d3e814c22b58b7b9fef732aea5e0ba054b1d181c93d4212de7
languageName: node
linkType: hard

"glob-parent@npm:^5.1.2, glob-parent@npm:~5.1.2":
version: 5.1.2
resolution: "glob-parent@npm:5.1.2"
Expand Down

0 comments on commit 46f4f36

Please sign in to comment.