mirror of
https://github.com/lutinglt/gitea-github-theme.git
synced 2025-10-26 13:00:31 +00:00
添加开发环境变量
This commit is contained in:
4
.env.example
Normal file
4
.env.example
Normal file
@@ -0,0 +1,4 @@
|
||||
DEV_THEME=dark
|
||||
SSH_SERVER=localhost
|
||||
SSH_USER=root
|
||||
GITEA_THEME_PATH=/data/gitea/public/assets/css/
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,3 +1,4 @@
|
||||
dist
|
||||
node_modules
|
||||
package-lock.json
|
||||
.env
|
||||
@@ -26,6 +26,7 @@
|
||||
"@vitejs/plugin-react-swc": "^3.10.2",
|
||||
"@wyw-in-js/babel-preset": "^0.7.0",
|
||||
"@wyw-in-js/vite": "^0.7.0",
|
||||
"dotenv": "^17.0.0",
|
||||
"eslint": "^9.29.0",
|
||||
"eslint-plugin-react-hooks": "^5.2.0",
|
||||
"eslint-plugin-react-refresh": "^0.4.20",
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { execSync } from "node:child_process";
|
||||
import crypto from "node:crypto";
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
@@ -46,6 +47,9 @@ export function themeInput(
|
||||
input[fileName] = tmpInputTs;
|
||||
}
|
||||
}
|
||||
if (mode === "dev") {
|
||||
console.log("[themeInput] devTheme:", devTheme);
|
||||
}
|
||||
return input;
|
||||
}
|
||||
|
||||
@@ -88,5 +92,22 @@ export function themePlugin(): Plugin {
|
||||
}
|
||||
}
|
||||
},
|
||||
closeBundle() {
|
||||
const server = process.env.SSH_SERVER;
|
||||
const user = process.env.SSH_USER || "root";
|
||||
const path = process.env.GITEA_THEME_PATH;
|
||||
if (server && path) {
|
||||
const cmd = `scp dist/${prefix}*.css ${user}@${server}:${path}`;
|
||||
console.log("[themePlugin] exec:", cmd);
|
||||
try {
|
||||
execSync(cmd, { stdio: "inherit" });
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
} catch (_) {
|
||||
// continue regardless of error
|
||||
}
|
||||
} else {
|
||||
console.log("[themePlugin] no SSH_SERVER or GITEA_THEME_PATH, skip upload");
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { vanillaExtractPlugin } from "@vanilla-extract/vite-plugin";
|
||||
import react from "@vitejs/plugin-react";
|
||||
import linaria from "@wyw-in-js/vite";
|
||||
import * as dotenv from "dotenv";
|
||||
import { Features } from "lightningcss";
|
||||
import { createRequire } from "node:module";
|
||||
import path from "node:path";
|
||||
@@ -8,9 +9,11 @@ import * as sass from "sass-embedded";
|
||||
import { defineConfig } from "vite";
|
||||
import { themeInput, themePlugin } from "./src/core/vite";
|
||||
|
||||
dotenv.config({quiet: true});
|
||||
|
||||
const require = createRequire(import.meta.url);
|
||||
|
||||
const devTheme = "dark"; // 开发模式仅打包单个颜色主题
|
||||
const devTheme = process.env.DEV_THEME || "dark"; // 开发模式下的主题, 仅打包该主题
|
||||
const outDir = "dist"; // 输出目录
|
||||
const themesDir = "themes"; // 颜色主题目录
|
||||
|
||||
|
||||
Reference in New Issue
Block a user