Quellcode durchsuchen

[stdf]更新svelte.config.js以支持404页面回退和动态基础路径配置;优化vite.config.ts中的插件配置;新增GitHub Actions工作流以自动部署Demo静态内容至GitHub Pages。

dufu1991 vor 1 Jahr
Ursprung
Commit
35e001ba5b

+ 52 - 0
packages/stdf/.github/workflows/releases-demo.yml

@@ -0,0 +1,52 @@
+# 将 Demo 静态内容部署到 GitHub Pages 的简易工作流程
+name: RELEASES DEMO
+
+name: Deploy to GitHub Pages
+
+on:
+  push:
+    branches: 'main'
+
+jobs:
+  build_site:
+    runs-on: ubuntu-latest
+    steps:
+      - name: Checkout
+        uses: actions/checkout@v4
+
+      - name: Install Node.js
+        uses: actions/setup-node@v4
+        with:
+        node-version: 20
+        cache: npm
+
+      - name: Install dependencies
+        run: npm install
+
+      - name: build
+        env:
+          BASE_PATH: '/${{ github.event.repository.name }}'
+        run: |
+          npm run build
+
+      - name: Upload Artifacts
+        uses: actions/upload-pages-artifact@v3
+        with:
+          path: 'build/'
+
+  deploy:
+    needs: build_site
+    runs-on: ubuntu-latest
+
+    permissions:
+      pages: write
+      id-token: write
+
+    environment:
+      name: github-pages
+      url: ${{ steps.deployment.outputs.page_url }}
+
+    steps:
+      - name: Deploy
+        id: deployment
+        uses: actions/deploy-pages@v4

+ 4 - 1
packages/stdf/svelte.config.js

@@ -8,7 +8,10 @@ const config = {
 	preprocess: vitePreprocess(),
 
 	kit: {
-		adapter: adapter()
+		adapter: adapter({ fallback: '404.html' }),
+		paths: {
+			base: process.argv.includes('dev') ? '' : process.env.BASE_PATH
+		}
 	}
 };
 

+ 6 - 16
packages/stdf/vite.config.ts

@@ -1,19 +1,9 @@
-import { sveltekit } from "@sveltejs/kit/vite";
-import { defineConfig } from "vite";
-import tailwindcss from "@tailwindcss/vite";
-import svgSprite from "rollup-plugin-stdf-icon";
+import { sveltekit } from '@sveltejs/kit/vite';
+import { defineConfig } from 'vite';
+import tailwindcss from '@tailwindcss/vite';
+import svgSprite from 'rollup-plugin-stdf-icon';
 
 export default defineConfig({
-	plugins: [
-		sveltekit(),
-		tailwindcss(),
-		svgSprite([
-			{
-				inFile: "src/assets/svgs",
-				outFile: "static/fonts",
-				fileName: "symbol",
-			},
-		]),
-	],
-	server: { hmr: true, host: "0.0.0.0", port: 8888 },
+	plugins: [sveltekit(), tailwindcss(), svgSprite([{ inFile: 'src/assets/svgs', outFile: 'static/fonts', fileName: 'symbol' }])],
+	server: { hmr: true, host: '0.0.0.0', port: 8888 }
 });