A modern, self-hosted backup solution for secure, encrypted backups across local and cloud storage.
refactor: frontend library css export.
towfiqi9cf2dd42c997
diff --git a/frontend/package.json b/frontend/package.jsonindex 3ffb87c..8688815 100644--- a/frontend/package.json+++ b/frontend/package.json@@ -1,7 +1,7 @@{"name": "@plutonhq/core-frontend","description": "Pluton Core Frontend Library",- "version": "0.1.0",+ "version": "0.1.5","author": "Plutonhq","license": "Apache-2.0","publishConfig": {@@ -82,8 +82,18 @@"types": "./dist-lib/routes/*/*.d.ts","import": "./dist-lib/routes/*/*.js"},- "./routes/*/*.module.scss": "./dist-lib/routes/*/*.module.scss.js",- "./components/*/*.module.scss": "./dist-lib/components/*/*.module.scss.js",+ "./routes/*/*.module.scss": {+ "import": "./dist-lib/routes/*/*.module.scss.js",+ "default": "./dist-lib/routes/*/*.module.scss.js"+ },+ "./components/*/*.module.scss": {+ "import": "./dist-lib/components/*/*.module.scss.js",+ "default": "./dist-lib/components/*/*.module.scss.js"+ },+ "./components/*/*/*.module.scss": {+ "import": "./dist-lib/components/*/*/*.module.scss.js",+ "default": "./dist-lib/components/*/*/*.module.scss.js"+ },"./routes/*/*": "./dist-lib/routes/*/*","./components/*/*": "./dist-lib/components/*/*","./services": {@@ -113,7 +123,9 @@"types": "./dist-lib/config/*.d.ts","import": "./dist-lib/config/*.js"},- "./styles/*": "./dist-lib/styles/*",+ "./styles/*.scss": "./dist-lib/styles/*.scss",+ "./styles/*.css": "./dist-lib/styles/*.css",+ "./styles/core-frontend.css": "./dist-lib/styles/core-frontend.css","./router": {"types": "./dist-lib/router.d.ts","import": "./dist-lib/router.js"diff --git a/frontend/src/styles/core-frontend.css b/frontend/src/styles/core-frontend.cssnew file mode 100644index 0000000..fe25fa8--- /dev/null+++ b/frontend/src/styles/core-frontend.css@@ -0,0 +1,8 @@+/*+ * Placeholder file for development mode.+ * In dev mode, Vite processes SCSS files on-the-fly, so CSS module styles are generated automatically.+ * In production builds (npm package), this file is replaced with the pre-compiled CSS bundle+ * containing all CSS module styles with consistent hashes.+ *+ * DO NOT add styles here - they will be overwritten in production.+ */diff --git a/frontend/vite.config.lib.ts b/frontend/vite.config.lib.tsindex abdbe27..1f747cf 100644--- a/frontend/vite.config.lib.ts+++ b/frontend/vite.config.lib.ts@@ -1,10 +1,14 @@import { defineConfig } from 'vite';import react from '@vitejs/plugin-react';-import { resolve } from 'path';+import { resolve, basename } from 'path';import { copyFileSync, mkdirSync, readdirSync, statSync } from 'fs';+import { createHash } from 'crypto';import { join, dirname } from 'path';-// Plugin to copy SCSS files to dist-lib+// Plugin to copy non-module SCSS files to dist-lib+// Module SCSS files are NOT copied because they're pre-compiled to .module.scss.js+// with consistent hashes. Only utility/mixin SCSS files are copied for @use/@extend.+// NOTE: core-frontend.css is excluded because Vite generates it with all compiled CSS modules.function copyScssPlugin() {return {name: 'copy-scss',@@ -17,16 +21,25 @@ function copyScssPlugin() {if (statSync(srcPath).isDirectory()) {copyScssFiles(srcPath, distPath);- } else if (entry.endsWith('.scss') || entry.endsWith('.css') || entry.endsWith('.png')) {+ } else if (entry.endsWith('.png')) {+ // Always copy imagesmkdirSync(dirname(distPath), { recursive: true });copyFileSync(srcPath, distPath);+ } else if (entry.endsWith('.scss') || entry.endsWith('.css')) {+ // Skip .module.scss files - they have pre-compiled .js mappings+ // Only copy utility SCSS files (mixins, variables, placeholders)+ // Also skip core-frontend.css - Vite generates this with compiled CSS modules+ if (!entry.includes('.module.') && entry !== 'core-frontend.css') {+ mkdirSync(dirname(distPath), { recursive: true });+ copyFileSync(srcPath, distPath);+ }}});};- // Copy SCSS files from src to dist-lib+ // Copy non-module SCSS files from src to dist-libcopyScssFiles(resolve(__dirname, 'src'), resolve(__dirname, 'dist-lib'));- console.log('✓ SCSS/CSS/PNG files copied to dist-lib');+ console.log('✓ Non-module SCSS/CSS/PNG files copied to dist-lib');},};}@@ -110,7 +123,14 @@ export default defineConfig(({ command, mode }) => ({},modules: {localsConvention: 'camelCase',- generateScopedName: '[name]__[local]___[hash:base64:5]',+ // Use content-based hash that's deterministic regardless of file path+ // This ensures the same hash is generated in library build and consumer builds+ generateScopedName: (name, filename, css) => {+ // Use only the filename (not full path) + class name + css content for hash+ const file = basename(filename).replace(/\.module\.s?css$/, '');+ const hash = createHash('md5').update(`${file}_${name}_${css}`).digest('base64').slice(0, 5).replace(/[+/=]/g, 'x');+ return `_${name}_${hash}`;+ },},},resolve: {diff --git a/frontend/vite.config.ts b/frontend/vite.config.tsindex dd7c057..e019119 100644--- a/frontend/vite.config.ts+++ b/frontend/vite.config.ts@@ -2,6 +2,8 @@ import { defineConfig, loadEnv } from 'vite';import react from '@vitejs/plugin-react';import { comlink } from 'vite-plugin-comlink';import { VitePWA } from 'vite-plugin-pwa';+import { createHash } from 'crypto';+import { basename } from 'path';// https://vite.dev/config/export default defineConfig(({ mode }) => {@@ -95,7 +97,13 @@ export default defineConfig(({ mode }) => {},css: {modules: {- generateScopedName: '_[local]_[hash:base64:5]',+ // Use content-based hash that's deterministic regardless of file path+ // This ensures the same hash is generated in library build and consumer builds+ generateScopedName: (name, filename, css) => {+ const file = basename(filename).replace(/\.module\.s?css$/, '');+ const hash = createHash('md5').update(`${file}_${name}_${css}`).digest('base64').slice(0, 5).replace(/[+/=]/g, 'x');+ return `_${name}_${hash}`;+ },localsConvention: 'camelCase',},preprocessorOptions: {