瀏覽代碼

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 年之前
父節點
當前提交
d939742c23
共有 2 個文件被更改,包括 8 次插入3 次删除
  1. 1
    1
      package.json
  2. 7
    2
      webpack-shared-config.js

+ 1
- 1
package.json 查看文件

@@ -65,7 +65,7 @@
65 65
   },
66 66
   "scripts": {
67 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 69
     "build:webpack-dev": "webpack --mode development",
70 70
     "build:tsc": "tsc --build --clean && tsc",
71 71
     "gen-types": "tsc --declaration --emitDeclarationOnly --out types/index.d.ts",

+ 7
- 2
webpack-shared-config.js 查看文件

@@ -1,10 +1,16 @@
1 1
 /* global __dirname */
2 2
 
3
+const { execSync } = require('child_process');
3 4
 const path = require('path');
4 5
 const process = require('process');
5 6
 const { IgnorePlugin, ProvidePlugin } = require('webpack');
6 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 15
 module.exports = (minimize, analyzeBundle) => {
10 16
     return {
@@ -24,8 +30,7 @@ module.exports = (minimize, analyzeBundle) => {
24 30
                 loader: 'string-replace-loader',
25 31
                 options: {
26 32
                     flags: 'g',
27
-                    replace:
28
-                        process.env.LIB_JITSI_MEET_COMMIT_HASH || 'development',
33
+                    replace: commitHash,
29 34
                     search: '{#COMMIT_HASH#}'
30 35
                 },
31 36
                 test: path.join(__dirname, 'JitsiMeetJS.ts')

Loading…
取消
儲存