Skip to content

The only tool you need to know what is happening and how to fix it.

support for plugin based css handling

ddux372b4fb7d26e
diff --git a/frontend/src/routes/layout.css b/frontend/src/routes/layout.css
index 8867ade5..1eafa68f 100644
--- a/frontend/src/routes/layout.css
+++ b/frontend/src/routes/layout.css
@@ -1,4 +1,5 @@
@import "tailwindcss";
+@source "$BILLING_PATH";
@import "tw-animate-css";
diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts
index 52400240..36c8618b 100644
--- a/frontend/vite.config.ts
+++ b/frontend/vite.config.ts
@@ -1,20 +1,37 @@
import tailwindcss from '@tailwindcss/vite';
import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig, loadEnv } from 'vite';
+import type { Plugin } from 'vite';
import { readFileSync, existsSync } from 'fs';
import path from 'path';
const pkg = JSON.parse(readFileSync('./package.json', 'utf-8'));
const billingPath = process.env.BILLING_PATH;
-const resolvedBillingPath = path.resolve(import.meta.dirname, billingPath);
-const billingExists = existsSync(resolvedBillingPath);
+const resolvedBillingPath = billingPath ? path.resolve(import.meta.dirname, billingPath) : null;
+const billingExists = resolvedBillingPath && existsSync(resolvedBillingPath);
+
+function injectBillingSource(): Plugin {
+ return {
+ name: 'inject-billing-source',
+ enforce: 'pre',
+ transform(code, id) {
+ if (id.endsWith('.css') && code.includes('@source "$BILLING_PATH"')) {
+ if (billingExists) {
+ return code.replace('@source "$BILLING_PATH"', `@source "${resolvedBillingPath}"`)
+ } else {
+ return code.replace('@source "$BILLING_PATH";', '')
+ }
+ }
+ }
+ }
+}
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), '');
return {
- plugins: [tailwindcss(), sveltekit()],
+ plugins: [injectBillingSource(), tailwindcss(), sveltekit()],
define: {
__APP_VERSION__: JSON.stringify(env.PUBLIC_APP_VERSION || pkg.version),
__CLOUD_MODE__: env.CLOUD_MODE,