Skip to content

Commit 2cfcd5a

Browse files
committed
ARTESCA-14679 // add version in remoteEntry file
1 parent ee5f03e commit 2cfcd5a

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

ui/rspack.config.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,25 @@ import packageJson from './package.json';
33
import { Configuration } from '@rspack/cli';
44
import rspack from '@rspack/core';
55
import { ModuleFederationPlugin } from '@module-federation/enhanced/rspack';
6+
import fs from 'fs';
67

78
const deps = packageJson.dependencies;
89

910
const isProduction = process.env.NODE_ENV === 'production';
1011

12+
let version = process.env.VERSION;
13+
if (!version) {
14+
const versionFileContents = fs.readFileSync(
15+
path.join(__dirname, '../VERSION'),
16+
{ encoding: 'utf-8' },
17+
);
18+
const versionRegex =
19+
/.*VERSION_MAJOR=(?<versionMajor>\d+)(\n){0,1}.*VERSION_MINOR=(?<versionMinor>\d+)(\n){0,1}.*VERSION_PATCH=(?<versionPatch>\d+)(\n){0,1}.*VERSION_SUFFIX=(?<versionSuffix>.*)/m;
20+
const { versionMajor, versionMinor, versionPatch, versionSuffix } =
21+
versionRegex.exec(versionFileContents).groups;
22+
version = `${versionMajor}.${versionMinor}.${versionPatch}${versionSuffix}`;
23+
}
24+
1125
const config: Configuration = {
1226
entry: {
1327
metalk8s_ui: './src/index.ts',
@@ -97,7 +111,7 @@ const config: Configuration = {
97111
plugins: [
98112
new ModuleFederationPlugin({
99113
name: 'metalk8s',
100-
filename: 'static/js/remoteEntry.js',
114+
filename: `static/js/remoteEntry.${version}.js`,
101115
exposes: {
102116
'./FederableApp': './src/FederableApp.tsx',
103117
'./platformLibrary': './src/services/platformlibrary/k8s.ts',

0 commit comments

Comments
 (0)