This is an automated email from the ASF dual-hosted git repository.

ovilia pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/echarts-theme-builder.git

commit d5960e3215d2e5b922f439da793151d4cb699954
Author: Ovilia <[email protected]>
AuthorDate: Mon Sep 15 19:43:17 2025 +0800

    chore: build
---
 package-lock.json |  18 +++++++++
 package.json      |   1 +
 vite.config.ts    | 110 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
 3 files changed, 128 insertions(+), 1 deletion(-)

diff --git a/package-lock.json b/package-lock.json
index e0f423a..2d242d5 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -15,6 +15,7 @@
         "vue3-colorpicker": "^2.3.0"
       },
       "devDependencies": {
+        "@types/node": "^24.4.0",
         "@vitejs/plugin-vue": "^6.0.1",
         "@vue/tsconfig": "^0.7.0",
         "typescript": "~5.8.3",
@@ -870,6 +871,16 @@
       "dev": true,
       "license": "MIT"
     },
+    "node_modules/@types/node": {
+      "version": "24.4.0",
+      "resolved": "https://registry.npmjs.org/@types/node/-/node-24.4.0.tgz";,
+      "integrity": 
"sha512-gUuVEAK4/u6F9wRLznPUU4WGUacSEBDPoC2TrBkw3GAnOLHBL45QdfHOXp1kJ4ypBGLxTOB+t7NJLpKoC3gznQ==",
+      "dev": true,
+      "license": "MIT",
+      "dependencies": {
+        "undici-types": "~7.11.0"
+      }
+    },
     "node_modules/@types/web-bluetooth": {
       "version": "0.0.20",
       "resolved": 
"https://registry.npmjs.org/@types/web-bluetooth/-/web-bluetooth-0.0.20.tgz";,
@@ -1522,6 +1533,13 @@
         "node": ">=14.17"
       }
     },
+    "node_modules/undici-types": {
+      "version": "7.11.0",
+      "resolved": 
"https://registry.npmjs.org/undici-types/-/undici-types-7.11.0.tgz";,
+      "integrity": 
"sha512-kt1ZriHTi7MU+Z/r9DOdAI3ONdaR3M3csEaRc6ewa4f4dTvX4cQCbJ4NkEn0ohE4hHtq85+PhPSTY+pO/1PwgA==",
+      "dev": true,
+      "license": "MIT"
+    },
     "node_modules/vant": {
       "version": "4.9.21",
       "resolved": "https://registry.npmjs.org/vant/-/vant-4.9.21.tgz";,
diff --git a/package.json b/package.json
index 238eda8..4054f72 100644
--- a/package.json
+++ b/package.json
@@ -16,6 +16,7 @@
     "vue3-colorpicker": "^2.3.0"
   },
   "devDependencies": {
+    "@types/node": "^24.4.0",
     "@vitejs/plugin-vue": "^6.0.1",
     "@vue/tsconfig": "^0.7.0",
     "typescript": "~5.8.3",
diff --git a/vite.config.ts b/vite.config.ts
index bbcf80c..adca3b2 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -1,7 +1,115 @@
 import { defineConfig } from 'vite'
 import vue from '@vitejs/plugin-vue'
+import path from 'path'
+import fs from 'fs'
 
 // https://vite.dev/config/
 export default defineConfig({
-  plugins: [vue()],
+  plugins: [
+    vue(),
+    {
+      name: 'theme-builder-post-process',
+      closeBundle: async () => {
+        // Handle HTML files
+        if (fs.existsSync('app/index.html')) {
+          // Create directories if they don't exist
+          if (!fs.existsSync('app/en')) {
+            fs.mkdirSync('app/en', { recursive: true });
+          }
+
+          // Read the content from index.html but only extract the body content
+          const content = fs.readFileSync('app/index.html', 'utf-8');
+          const bodyContent = content.match(/<body>(.*?)<\/body>/s)?.[1] || '';
+
+          // Write to body.html for English version
+          fs.writeFileSync('app/en/body.html', bodyContent.trim(), 'utf-8');
+
+          // Do the same for zh version
+          if (!fs.existsSync('app/zh')) {
+            fs.mkdirSync('app/zh', { recursive: true });
+          }
+          fs.writeFileSync('app/zh/body.html', bodyContent.trim(), 'utf-8');
+
+          // Remove the original index.html
+          fs.unlinkSync('app/index.html');
+        }
+        
+        // Move CSS file to app/styles directory (common for both languages)
+        if (fs.existsSync('app/en/theme-builder/main.css')) {
+          const stylesDir = 'app/styles';
+          if (!fs.existsSync(stylesDir)) {
+            fs.mkdirSync(stylesDir, { recursive: true });
+          }
+          
+          // Move CSS to shared styles directory
+          fs.copyFileSync('app/en/theme-builder/main.css', 
`${stylesDir}/main.css`);
+          
+          // Clean up the language-specific CSS files
+          if (fs.existsSync('app/en/theme-builder/main.css')) {
+            fs.unlinkSync('app/en/theme-builder/main.css');
+          }
+        }
+        
+        // Create shared assets directory if needed
+        const sharedAssetsDir = 'app/assets';
+        if (!fs.existsSync(sharedAssetsDir)) {
+          fs.mkdirSync(sharedAssetsDir, { recursive: true });
+        }
+
+        // Copy theme files to app root directory
+        const themesDir = 'public/themes';
+        const themesDestination = 'app/themes';
+
+        if (fs.existsSync(themesDir)) {
+          // Create themes directory in app root
+          if (!fs.existsSync(themesDestination)) {
+            fs.mkdirSync(themesDestination, { recursive: true });
+          }
+
+          // Copy theme files to app/themes
+          fs.readdirSync(themesDir).forEach((file: string) => {
+            if (file.endsWith('.json')) {
+              fs.copyFileSync(`${themesDir}/${file}`, 
`${themesDestination}/${file}`);
+            }
+          });
+        }
+      }
+    }
+  ],
+  build: {
+    outDir: 'app',
+    emptyOutDir: true,
+    rollupOptions: {
+      input: {
+        'main': path.resolve(process.cwd(), 'index.html')
+      },
+      output: {
+        entryFileNames: (chunkInfo) => {
+          const locale = chunkInfo.facadeModuleId?.includes('/en/') ? 'en' : 
'zh';
+          return `${locale}/theme-builder/app.min.js`;
+        },
+        chunkFileNames: (chunkInfo) => {
+          const name = chunkInfo.name || '';
+          const locale = name.includes('en') ? 'en' : 'zh';
+          return `${locale}/theme-builder/chunks/[name]-[hash].js`;
+        },
+        assetFileNames: (assetInfo) => {
+          const info = assetInfo.name || '';
+          
+          // For CSS files, put them in shared styles directory
+          if (info.endsWith('.css')) {
+            return `styles/main.css`;
+          }
+          
+          // Common assets go to app root, others to language-specific 
directories
+          if (info.includes('assets/') || info.includes('images/')) {
+            return `assets/[name]-[hash][extname]`;
+          }
+
+          return `en/theme-builder/assets/[name]-[hash][extname]`;
+        },
+        manualChunks: undefined
+      }
+    }
+  }
 })


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to