Browse Source

feat(build) remove export from build script

this moves the determination of the git commit to webpack-shared-config
LIB_JITSI_MEET_COMMIT_HASH is still kept for backward compatibility

fix(build) in case git fails use development
release-8443
Jorge Oliveira 3 years ago
parent
commit
d939742c23
2 changed files with 8 additions and 3 deletions
  1. 1
    1
      package.json
  2. 7
    2
      webpack-shared-config.js

+ 1
- 1
package.json View File

65
   },
65
   },
66
   "scripts": {
66
   "scripts": {
67
     "build": "npm run build:webpack && npm run build:tsc",
67
     "build": "npm run build:webpack && npm run build:tsc",
68
-    "build:webpack": "LIB_JITSI_MEET_COMMIT_HASH=$(git rev-parse --short HEAD 2>/dev/null) webpack",
68
+    "build:webpack": "webpack",
69
     "build:webpack-dev": "webpack --mode development",
69
     "build:webpack-dev": "webpack --mode development",
70
     "build:tsc": "tsc --build --clean && tsc",
70
     "build:tsc": "tsc --build --clean && tsc",
71
     "gen-types": "tsc --declaration --emitDeclarationOnly --out types/index.d.ts",
71
     "gen-types": "tsc --declaration --emitDeclarationOnly --out types/index.d.ts",

+ 7
- 2
webpack-shared-config.js View File

1
 /* global __dirname */
1
 /* global __dirname */
2
 
2
 
3
+const { execSync } = require('child_process');
3
 const path = require('path');
4
 const path = require('path');
4
 const process = require('process');
5
 const process = require('process');
5
 const { IgnorePlugin, ProvidePlugin } = require('webpack');
6
 const { IgnorePlugin, ProvidePlugin } = require('webpack');
6
 const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
7
 const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
7
 
8
 
9
+const devNull = process.platform === 'win32' ? 'nul' : '/dev/null';
10
+const commitHash = process.env.LIB_JITSI_MEET_COMMIT_HASH
11
+    || execSync(`git rev-parse --short HEAD 2>${devNull} || echo development`)
12
+        .toString()
13
+        .trim();
8
 
14
 
9
 module.exports = (minimize, analyzeBundle) => {
15
 module.exports = (minimize, analyzeBundle) => {
10
     return {
16
     return {
24
                 loader: 'string-replace-loader',
30
                 loader: 'string-replace-loader',
25
                 options: {
31
                 options: {
26
                     flags: 'g',
32
                     flags: 'g',
27
-                    replace:
28
-                        process.env.LIB_JITSI_MEET_COMMIT_HASH || 'development',
33
+                    replace: commitHash,
29
                     search: '{#COMMIT_HASH#}'
34
                     search: '{#COMMIT_HASH#}'
30
                 },
35
                 },
31
                 test: path.join(__dirname, 'JitsiMeetJS.ts')
36
                 test: path.join(__dirname, 'JitsiMeetJS.ts')

Loading…
Cancel
Save