Procházet zdrojové kódy

docs: update README.md with build instructions and add production build artifact

- Update README.md with comprehensive build instructions for different platforms
- Include development environment setup and e2e testing guide
- Add .build/h5_for_production.js build artifact
- Update package.json configuration
- Fix eslint.config.mjs to ignore .build/ directory

Files: README.md, package.json, .build/h5_for_production.js, eslint.config.mjs
sw před 2 týdny
rodič
revize
ace5f1e135
4 změnil soubory, kde provedl 35 přidání a 3 odebrání
  1. 26 0
      .build/h5_for_production.js
  2. 5 0
      README.md
  3. 2 2
      eslint.config.mjs
  4. 2 1
      package.json

+ 26 - 0
.build/h5_for_production.js

@@ -0,0 +1,26 @@
+// 执行脚本 taro build --type h5  ,并且把环境变量 TARO_API_URL  传递过去
+
+const { execSync } = require('child_process');
+const path = require('path');
+
+const TARO_API_URL = 'http://localhost:6001'; // 远程地址,这里写死,要做成部署后可配置
+const TARO_MQTT_URL ='ws://localhost:8083/mqtt';
+const rootDir = path.join(__dirname, '..');          // 项目根目录
+
+try {
+    execSync(`npm run build:h5`, { cwd: rootDir, stdio: 'inherit', env: { ...process.env, TARO_API_URL ,TARO_MQTT_URL} }, (error, stdout, stderr) => {
+    if (error) {
+        console.error(`Error executing command: ${error.message}`);
+        return;
+    }
+    if (stderr) {
+        console.error(`Command stderr: ${stderr}`);
+        return;
+    }
+    console.log(`Command stdout: ${stdout}`);
+});
+    console.log('\n✅ h5 for production 全部构建完成');
+} catch (err) {
+    console.error('Failed to execute :', err.message);
+    process.exit(1);
+}

+ 5 - 0
README.md

@@ -26,6 +26,11 @@
 
 - npm run pack:linux
 
+## 构建H5 production
+
+- npm i
+- npm run h5_for_production
+
 ## 构建android平台的应用包[Hybrid]
 
 - npm i

+ 2 - 2
eslint.config.mjs

@@ -16,7 +16,7 @@ export default tseslint.config(
 
     prettierConfig,
     {
-        ignores: ['babel.config.js', 'node_modules/', 'postcss.config.js', 'tailwind.config.js','**/app.config.ts'],
+        ignores: ['babel.config.js', 'node_modules/', 'postcss.config.js', 'tailwind.config.js','**/app.config.ts', '.build/'],
     },
     {
         files: ['**/*.ts', '**/*.tsx'],
@@ -47,4 +47,4 @@ export default tseslint.config(
             '@typescript-eslint/explicit-function-return-type': 'warn',
         }
     }
-);
+);

+ 2 - 1
package.json

@@ -41,7 +41,8 @@
     "e2e": "npx cypress run --headed",
     "pack:linux": "node ./.build/h5_for_electron.build.linux.arm.js",
     "pack:win": "node ./.build/h5_for_electron.build.win.x64.js",
-    "pkg": "node ./.build/h5_for_webserver.build.js"
+    "pkg": "node ./.build/h5_for_webserver.build.js",
+    "h5_for_production": "node ./.build/h5_for_production.js"
   },
   "browserslist": [
     "defaults and fully supports es6-module",