Skip to content

Commit

Permalink
chore: 添加插件调试网页部署指令
Browse files Browse the repository at this point in the history
  • Loading branch information
TBXark committed Aug 28, 2024
1 parent 0cbeee6 commit 30d7f0e
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 4 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,5 @@ out
/config.json
/wrangler.toml
/wrangler-test.toml
/plugins/interpolate.js
/dist/index.cjs
/dist/index.d.ts
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"deploy:dist": "wrangler deploy",
"deploy:build": "npm run build && wrangler deploy",
"deploy:vercel": "vercel deploy --prod",
"deploy:plugin": "BUILD_MODE=plugins-page vite build && wrangler pages deploy plugins",
"start:dist": "node dist/index.js",
"start:local": "CONFIG_PATH=./config.json TOML_PATH=./wrangler.toml tsx src/adapter/local/index.ts",
"start:debug": "wrangler dev --local",
Expand Down
1 change: 1 addition & 0 deletions plugins/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/dist
4 changes: 2 additions & 2 deletions plugins/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ChatGPT-Telegram-Workers</title>
<script type="module" src="interpolate.js"></script>
<script type="module" src="dist/interpolate.js"></script>
<style>
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
Expand Down Expand Up @@ -133,7 +133,7 @@ <h2>preview</h2>

<script type="module">

import { interpolate } from './interpolate.js';
import { interpolate } from './dist/interpolate.js';

function updatePreview() {
const template = document.getElementById('template').value;
Expand Down
10 changes: 9 additions & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,15 @@ const plugins: Plugin[] = [
];

let entry: string;
let outDir = 'dist';
let fileName = 'index';
let formats: LibraryFormats[] = ['es'];
switch (BUILD_MODE) {
case 'plugins-page':
entry = 'src/plugins/interpolate.ts';
fileName = 'interpolate';
outDir = 'plugins/dist';
break;
case 'local':
entry = 'src/adapter/local/index.ts';
plugins.push(createDockerPlugin('dist'));
Expand All @@ -53,10 +60,11 @@ export default defineConfig({
target: 'esnext',
lib: {
entry: path.resolve(__dirname, entry),
fileName: 'index',
fileName,
formats,
},
minify: false,
outDir,
},
define: {
...versionDefine,
Expand Down

0 comments on commit 30d7f0e

Please sign in to comment.