Sfoglia il codice sorgente

feat:测试服配置

mickey135 2 mesi fa
parent
commit
6326d803b8
3 ha cambiato i file con 57 aggiunte e 0 eliminazioni
  1. 1 0
      .node-version
  2. 51 0
      gulpfile.mjs
  3. 5 0
      package.json

+ 1 - 0
.node-version

@@ -0,0 +1 @@
+20.15.0

+ 51 - 0
gulpfile.mjs

@@ -0,0 +1,51 @@
+import gulp from 'gulp';
+import shell from 'gulp-shell';
+import gulp_zip from 'gulp-zip';
+
+const { series } = gulp;
+
+const dev_server = 'dev:/data/projects/precaution/mobile'; // 开发服务器地址
+const stage_server = 'dev:/data/projects/precaution/mobile'; // 预生产服务器地址
+const prod_server = 'hejin-online:/data/hejin'; // 生产服务器地址
+
+const zipfile = 'precaution-mobile.zip';
+const srcfiles = ['dist/**/*'];
+const basePath = './dist';
+
+let serverValue = '';
+let serverPathValue = '';
+
+function prepare(server) {
+  return cb => {
+    const parts = server.split(':');
+    serverValue = parts[0];
+    serverPathValue = parts[1];
+    cb();
+  };
+}
+
+function zip() {
+  return gulp.src(srcfiles, { base: basePath, encoding: false }).pipe(gulp_zip(zipfile)).pipe(gulp.dest('./dist'));
+}
+
+function compile() {
+  return shell.task('vite build')();
+}
+
+function compileStage() {
+  //return shell.task('ng build --configuration=staging')();
+  return shell.task('vite build')();
+}
+
+function upload() {
+  return shell.task(`scp ./dist/${zipfile} ${serverValue}:${serverPathValue}/${zipfile}`)();
+}
+
+function unzip() {
+  return shell.task(`ssh ${serverValue} "cd ${serverPathValue} && unzip -o ${zipfile}"`)();
+}
+
+export const build = series(compile, zip);
+export const prod = series(prepare(prod_server), compile, zip, upload, unzip);
+export const dev = series(prepare(dev_server), compile, zip, upload, unzip);
+export const stage = series(prepare(stage_server), compileStage, zip, upload, unzip);

+ 5 - 0
package.json

@@ -4,8 +4,10 @@
   "version": "0.0.0",
   "type": "module",
   "scripts": {
+    "start": "vite --mode local",
     "dev": "vite",
     "build": "tsc -b && vite build",
+    "publish:dev": "gulp dev",
     "lint": "eslint .",
     "format": "prettier --write \"src/**/*.(ts|tsx|html|css|scss|less)\"",
     "preview": "vite preview"
@@ -32,6 +34,9 @@
     "@types/react": "^18.3.12",
     "@types/react-dom": "^18.3.1",
     "@vitejs/plugin-react-swc": "^3.5.0",
+    "gulp": "^5.0.0",
+    "gulp-shell": "^0.8.0",
+    "gulp-zip": "^6.0.0",
     "eslint": "^9.13.0",
     "eslint-plugin-react-hooks": "^5.0.0",
     "eslint-plugin-react-refresh": "^0.4.14",